x86, xsave: Cleanup return codes in check_for_xstate()
The places which call check_for_xstate() only care about zero or non-zero so this patch doesn't change how the code runs, but it's a cleanup. The main reason for this patch is that I'm looking for places which don't return -EFAULT for copy_from_user() failures. Signed-off-by: Dan Carpenter <error27@gmail.com> LKML-Reference: <20100603100746.GU5483@bicker> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com> Cc: Suresh Siddha <suresh.b.siddha@intel.com>
This commit is contained in:
committed by
H. Peter Anvin
parent
e44a21b726
commit
d6d4d4205c
@@ -36,15 +36,14 @@ int check_for_xstate(struct i387_fxsave_struct __user *buf,
|
|||||||
|
|
||||||
err = __copy_from_user(fx_sw_user, &buf->sw_reserved[0],
|
err = __copy_from_user(fx_sw_user, &buf->sw_reserved[0],
|
||||||
sizeof(struct _fpx_sw_bytes));
|
sizeof(struct _fpx_sw_bytes));
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return -EFAULT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First Magic check failed.
|
* First Magic check failed.
|
||||||
*/
|
*/
|
||||||
if (fx_sw_user->magic1 != FP_XSTATE_MAGIC1)
|
if (fx_sw_user->magic1 != FP_XSTATE_MAGIC1)
|
||||||
return -1;
|
return -EINVAL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for error scenarios.
|
* Check for error scenarios.
|
||||||
@@ -52,19 +51,21 @@ int check_for_xstate(struct i387_fxsave_struct __user *buf,
|
|||||||
if (fx_sw_user->xstate_size < min_xstate_size ||
|
if (fx_sw_user->xstate_size < min_xstate_size ||
|
||||||
fx_sw_user->xstate_size > xstate_size ||
|
fx_sw_user->xstate_size > xstate_size ||
|
||||||
fx_sw_user->xstate_size > fx_sw_user->extended_size)
|
fx_sw_user->xstate_size > fx_sw_user->extended_size)
|
||||||
return -1;
|
return -EINVAL;
|
||||||
|
|
||||||
err = __get_user(magic2, (__u32 *) (((void *)fpstate) +
|
err = __get_user(magic2, (__u32 *) (((void *)fpstate) +
|
||||||
fx_sw_user->extended_size -
|
fx_sw_user->extended_size -
|
||||||
FP_XSTATE_MAGIC2_SIZE));
|
FP_XSTATE_MAGIC2_SIZE));
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
/*
|
/*
|
||||||
* Check for the presence of second magic word at the end of memory
|
* Check for the presence of second magic word at the end of memory
|
||||||
* layout. This detects the case where the user just copied the legacy
|
* layout. This detects the case where the user just copied the legacy
|
||||||
* fpstate layout with out copying the extended state information
|
* fpstate layout with out copying the extended state information
|
||||||
* in the memory layout.
|
* in the memory layout.
|
||||||
*/
|
*/
|
||||||
if (err || magic2 != FP_XSTATE_MAGIC2)
|
if (magic2 != FP_XSTATE_MAGIC2)
|
||||||
return -1;
|
return -EFAULT;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user