[PATCH] staging: lustre: return error if copy_to_user fails
Gujulan Elango, Hari Prasath (H.)
hgujulan at visteon.com
Thu May 14 09:52:03 UTC 2015
On Thu, May 14, 2015 at 12:47:19PM +0300, Dan Carpenter wrote:
> 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 at visteon.com>
> > ---
> > 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
>
I was little skeptical when sending this patch.I agree with you and we
shall wait for comments from lustre developers.May be if it was
purposeful,they could have left out a comment.
More information about the devel
mailing list