2019-08-21 07:11:24

by Dan Carpenter

[permalink] [raw]
Subject: [PATCH 2/4] misc: xilinx_sdfec: Return -EFAULT if copy_from_user() fails

The copy_from_user() funciton returns the number of bytes remaining to
be copied but we want to return -EFAULT to the user.

Fixes: 20ec628e8007 ("misc: xilinx_sdfec: Add ability to configure LDPC")
Signed-off-by: Dan Carpenter <[email protected]>
---
drivers/misc/xilinx_sdfec.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/xilinx_sdfec.c b/drivers/misc/xilinx_sdfec.c
index dc1b8b412712..813b82c59360 100644
--- a/drivers/misc/xilinx_sdfec.c
+++ b/drivers/misc/xilinx_sdfec.c
@@ -651,9 +651,10 @@ static int xsdfec_add_ldpc(struct xsdfec_dev *xsdfec, void __user *arg)
if (!ldpc)
return -ENOMEM;

- ret = copy_from_user(ldpc, arg, sizeof(*ldpc));
- if (ret)
+ if (copy_from_user(ldpc, arg, sizeof(*ldpc))) {
+ ret = -EFAULT;
goto err_out;
+ }

if (xsdfec->config.code == XSDFEC_TURBO_CODE) {
ret = -EIO;
--
2.20.1


2019-08-22 10:40:04

by Michal Simek

[permalink] [raw]
Subject: Re: [PATCH 2/4] misc: xilinx_sdfec: Return -EFAULT if copy_from_user() fails

On 21. 08. 19 9:07, Dan Carpenter wrote:
> The copy_from_user() funciton returns the number of bytes remaining to

typo here.

> be copied but we want to return -EFAULT to the user.
>
> Fixes: 20ec628e8007 ("misc: xilinx_sdfec: Add ability to configure LDPC")
> Signed-off-by: Dan Carpenter <[email protected]>
> ---
> drivers/misc/xilinx_sdfec.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/misc/xilinx_sdfec.c b/drivers/misc/xilinx_sdfec.c
> index dc1b8b412712..813b82c59360 100644
> --- a/drivers/misc/xilinx_sdfec.c
> +++ b/drivers/misc/xilinx_sdfec.c
> @@ -651,9 +651,10 @@ static int xsdfec_add_ldpc(struct xsdfec_dev *xsdfec, void __user *arg)
> if (!ldpc)
> return -ENOMEM;
>
> - ret = copy_from_user(ldpc, arg, sizeof(*ldpc));
> - if (ret)
> + if (copy_from_user(ldpc, arg, sizeof(*ldpc))) {
> + ret = -EFAULT;
> goto err_out;
> + }
>
> if (xsdfec->config.code == XSDFEC_TURBO_CODE) {
> ret = -EIO;
>

When typo fixed feel free to add my
Reviewed-by: Michal Simek <[email protected]>

Thanks,
Michal

2019-08-22 10:57:33

by Dan Carpenter

[permalink] [raw]
Subject: [PATCH 2/4 v2] misc: xilinx_sdfec: Return -EFAULT if copy_from_user() fails

The copy_from_user() function returns the number of bytes remaining to
be copied but we want to return -EFAULT to the user.

Fixes: 20ec628e8007 ("misc: xilinx_sdfec: Add ability to configure LDPC")
Signed-off-by: Dan Carpenter <[email protected]>
Reviewed-by: Michal Simek <[email protected]>
---
v2: Fix a typo in the commit message. funciton --> function

drivers/misc/xilinx_sdfec.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/xilinx_sdfec.c b/drivers/misc/xilinx_sdfec.c
index dc1b8b412712..813b82c59360 100644
--- a/drivers/misc/xilinx_sdfec.c
+++ b/drivers/misc/xilinx_sdfec.c
@@ -651,9 +651,10 @@ static int xsdfec_add_ldpc(struct xsdfec_dev *xsdfec, void __user *arg)
if (!ldpc)
return -ENOMEM;

- ret = copy_from_user(ldpc, arg, sizeof(*ldpc));
- if (ret)
+ if (copy_from_user(ldpc, arg, sizeof(*ldpc))) {
+ ret = -EFAULT;
goto err_out;
+ }

if (xsdfec->config.code == XSDFEC_TURBO_CODE) {
ret = -EIO;
--
2.20.1

2019-08-23 11:58:21

by Dragan Cvetic

[permalink] [raw]
Subject: RE: [PATCH 2/4] misc: xilinx_sdfec: Return -EFAULT if copy_from_user() fails

Hi Dan,

> -----Original Message-----
> From: Dan Carpenter [mailto:[email protected]]
> Sent: Wednesday 21 August 2019 08:07
> To: Derek Kiernan <[email protected]>; Dragan Cvetic <[email protected]>
> Cc: Arnd Bergmann <[email protected]>; Greg Kroah-Hartman <[email protected]>; Michal Simek <[email protected]>;
> [email protected]; [email protected]; [email protected]
> Subject: [PATCH 2/4] misc: xilinx_sdfec: Return -EFAULT if copy_from_user() fails
>
> The copy_from_user() funciton returns the number of bytes remaining to
> be copied but we want to return -EFAULT to the user.
>
> Fixes: 20ec628e8007 ("misc: xilinx_sdfec: Add ability to configure LDPC")
> Signed-off-by: Dan Carpenter <[email protected]>
> ---
> drivers/misc/xilinx_sdfec.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/misc/xilinx_sdfec.c b/drivers/misc/xilinx_sdfec.c
> index dc1b8b412712..813b82c59360 100644
> --- a/drivers/misc/xilinx_sdfec.c
> +++ b/drivers/misc/xilinx_sdfec.c
> @@ -651,9 +651,10 @@ static int xsdfec_add_ldpc(struct xsdfec_dev *xsdfec, void __user *arg)
> if (!ldpc)
> return -ENOMEM;
>
> - ret = copy_from_user(ldpc, arg, sizeof(*ldpc));
> - if (ret)
> + if (copy_from_user(ldpc, arg, sizeof(*ldpc))) {
> + ret = -EFAULT;
> goto err_out;
> + }
>
> if (xsdfec->config.code == XSDFEC_TURBO_CODE) {
> ret = -EIO;
> --
> 2.20.1

Reviewed-by: Dragan Cvetic <[email protected]>

Thanks,
Dragan