Re: [PATCH] staging: lustre: return error if copy_to_user fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 14, 2015 at 09:22:01AM +0000, Gujulan Elango, Hari Prasath (H.) wrote:
> The return value of copy_to_user() isn't checked for failure.Hence
> return -EFAULT if it fails.
> 
> Signed-off-by: Hari Prasath Gujulan Elango <hgujulan@xxxxxxxxxxx>
> ---
>  drivers/staging/lustre/lustre/lov/lov_pack.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c
> index 5356d53..aa3d6de 100644
> --- a/drivers/staging/lustre/lustre/lov/lov_pack.c
> +++ b/drivers/staging/lustre/lustre/lov/lov_pack.c
> @@ -448,9 +448,10 @@ int lov_getstripe(struct obd_export *exp, struct lov_stripe_md *lsm,
>  	    (lum.lmm_stripe_count < lsm->lsm_stripe_count)) {
>  		/* Return right size of stripe to user */
>  		lum.lmm_stripe_count = lsm->lsm_stripe_count;
> -		rc = copy_to_user(lump, &lum, lum_size);
> -		rc = -EOVERFLOW;
> -		goto out_set;
> +		if (copy_to_user(lump, &lum, lum_size)) {
> +			rc = -EFAULT;
> +			goto out_set;
> +		}

I'm not sure this is right, and I don't think we should take it without
some lustre people signing off.

The original code looks deliberate, like the error happened earlier and
if the copy_to_user() succeed that's fine because it gives them a hint
what went wrong, but we want to return an error -EOVERFLOW regardless of
if the copy_to_user() works or not.

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux