[PATCH] fsi: i2cr-scom: Fix error code in read/write

Dan Carpenter dan.carpenter at linaro.org
Mon Apr 8 19:57:52 AEST 2024


On Mon, Oct 02, 2023 at 09:57:22AM -0500, Eddie James wrote:
> 
> On 9/7/23 04:55, Dan Carpenter wrote:
> > The copy_to/from_user() functions return the number of bytes that they
> > were not able to copy but we want to return negative -EFAULT to the
> > user.
> 
> 
> Thanks.
> 
> Reviewed-by: Eddie James <eajames at linux.ibm.com>
> 

This was never merged.

regards,
dan carpenter


> 
> > 
> > Fixes: c0b34bed0bbf ("fsi: Add I2C Responder SCOM driver")
> > Signed-off-by: Dan Carpenter <dan.carpenter at linaro.org>
> > ---
> >   drivers/fsi/i2cr-scom.c | 10 ++++------
> >   1 file changed, 4 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/fsi/i2cr-scom.c b/drivers/fsi/i2cr-scom.c
> > index cb7e02213032..df1e1df40332 100644
> > --- a/drivers/fsi/i2cr-scom.c
> > +++ b/drivers/fsi/i2cr-scom.c
> > @@ -45,9 +45,8 @@ static ssize_t i2cr_scom_read(struct file *filep, char __user *buf, size_t len,
> >   	if (ret)
> >   		return ret;
> > -	ret = copy_to_user(buf, &data, len);
> > -	if (ret)
> > -		return ret;
> > +	if (copy_to_user(buf, &data, len))
> > +		return -EFAULT;
> >   	return len;
> >   }
> > @@ -62,9 +61,8 @@ static ssize_t i2cr_scom_write(struct file *filep, const char __user *buf, size_
> >   	if (len != sizeof(data))
> >   		return -EINVAL;
> > -	ret = copy_from_user(&data, buf, len);
> > -	if (ret)
> > -		return ret;
> > +	if (copy_from_user(&data, buf, len))
> > +		return -EFAULT;
> >   	ret = fsi_master_i2cr_write(scom->i2cr, (u32)*offset, data);
> >   	if (ret)


More information about the linux-fsi mailing list