mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ACPI: APEI: Remove redundant assignments in erst_dbg_{ioctl|write}()
@ 2025-09-03 22:49 Thorsten Blum
  2025-09-05  1:19 ` Shuai Xue
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Blum @ 2025-09-03 22:49 UTC (permalink / raw)
  To: Rafael J. Wysocki, Tony Luck, Borislav Petkov, Hanjun Guo,
	Mauro Carvalho Chehab, Shuai Xue, Len Brown, Al Viro
  Cc: Thorsten Blum, linux-acpi, linux-kernel

Use the result of copy_from_user() directly instead of assigning it to
the local variable 'rc' and then overwriting it in erst_dbg_write() or
immediately returning from erst_dbg_ioctl().

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/acpi/apei/erst-dbg.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/apei/erst-dbg.c b/drivers/acpi/apei/erst-dbg.c
index 246076341e8c..ff0e8bf8e97a 100644
--- a/drivers/acpi/apei/erst-dbg.c
+++ b/drivers/acpi/apei/erst-dbg.c
@@ -60,9 +60,8 @@ static long erst_dbg_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
 
 	switch (cmd) {
 	case APEI_ERST_CLEAR_RECORD:
-		rc = copy_from_user(&record_id, (void __user *)arg,
-				    sizeof(record_id));
-		if (rc)
+		if (copy_from_user(&record_id, (void __user *)arg,
+				   sizeof(record_id)))
 			return -EFAULT;
 		return erst_clear(record_id);
 	case APEI_ERST_GET_RECORD_COUNT:
@@ -175,8 +174,7 @@ static ssize_t erst_dbg_write(struct file *filp, const char __user *ubuf,
 		erst_dbg_buf = p;
 		erst_dbg_buf_len = usize;
 	}
-	rc = copy_from_user(erst_dbg_buf, ubuf, usize);
-	if (rc) {
+	if (copy_from_user(erst_dbg_buf, ubuf, usize)) {
 		rc = -EFAULT;
 		goto out;
 	}
-- 
2.51.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ACPI: APEI: Remove redundant assignments in erst_dbg_{ioctl|write}()
  2025-09-03 22:49 [PATCH] ACPI: APEI: Remove redundant assignments in erst_dbg_{ioctl|write}() Thorsten Blum
@ 2025-09-05  1:19 ` Shuai Xue
  2025-09-15 19:22   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Shuai Xue @ 2025-09-05  1:19 UTC (permalink / raw)
  To: Thorsten Blum, Rafael J. Wysocki, Tony Luck, Borislav Petkov,
	Hanjun Guo, Mauro Carvalho Chehab, Len Brown, Al Viro
  Cc: linux-acpi, linux-kernel



在 2025/9/4 06:49, Thorsten Blum 写道:
> Use the result of copy_from_user() directly instead of assigning it to
> the local variable 'rc' and then overwriting it in erst_dbg_write() or
> immediately returning from erst_dbg_ioctl().
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>   drivers/acpi/apei/erst-dbg.c | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/acpi/apei/erst-dbg.c b/drivers/acpi/apei/erst-dbg.c
> index 246076341e8c..ff0e8bf8e97a 100644
> --- a/drivers/acpi/apei/erst-dbg.c
> +++ b/drivers/acpi/apei/erst-dbg.c
> @@ -60,9 +60,8 @@ static long erst_dbg_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
>   
>   	switch (cmd) {
>   	case APEI_ERST_CLEAR_RECORD:
> -		rc = copy_from_user(&record_id, (void __user *)arg,
> -				    sizeof(record_id));
> -		if (rc)
> +		if (copy_from_user(&record_id, (void __user *)arg,
> +				   sizeof(record_id)))
>   			return -EFAULT;
>   		return erst_clear(record_id);
>   	case APEI_ERST_GET_RECORD_COUNT:
> @@ -175,8 +174,7 @@ static ssize_t erst_dbg_write(struct file *filp, const char __user *ubuf,
>   		erst_dbg_buf = p;
>   		erst_dbg_buf_len = usize;
>   	}
> -	rc = copy_from_user(erst_dbg_buf, ubuf, usize);
> -	if (rc) {
> +	if (copy_from_user(erst_dbg_buf, ubuf, usize)) {
>   		rc = -EFAULT;
>   		goto out;
>   	}

Hi Thorsten,
Thanks for the patch.

The changes look good to me.

Since this is a code cleanup with no functional changes, could you
please mention "no functional change" or similar wording in the commit
message to make it clear?

With that addressed:
Reviewed-by: Shuai Xue <xueshuai@linux.alibaba.com>

Thanks,
Shuai

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ACPI: APEI: Remove redundant assignments in erst_dbg_{ioctl|write}()
  2025-09-05  1:19 ` Shuai Xue
@ 2025-09-15 19:22   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2025-09-15 19:22 UTC (permalink / raw)
  To: Shuai Xue, Thorsten Blum
  Cc: Tony Luck, Borislav Petkov, Hanjun Guo, Mauro Carvalho Chehab,
	Len Brown, Al Viro, linux-acpi, linux-kernel

On Fri, Sep 5, 2025 at 3:19 AM Shuai Xue <xueshuai@linux.alibaba.com> wrote:
>
>
>
> 在 2025/9/4 06:49, Thorsten Blum 写道:
> > Use the result of copy_from_user() directly instead of assigning it to
> > the local variable 'rc' and then overwriting it in erst_dbg_write() or
> > immediately returning from erst_dbg_ioctl().
> >
> > Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> > ---
> >   drivers/acpi/apei/erst-dbg.c | 8 +++-----
> >   1 file changed, 3 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/acpi/apei/erst-dbg.c b/drivers/acpi/apei/erst-dbg.c
> > index 246076341e8c..ff0e8bf8e97a 100644
> > --- a/drivers/acpi/apei/erst-dbg.c
> > +++ b/drivers/acpi/apei/erst-dbg.c
> > @@ -60,9 +60,8 @@ static long erst_dbg_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
> >
> >       switch (cmd) {
> >       case APEI_ERST_CLEAR_RECORD:
> > -             rc = copy_from_user(&record_id, (void __user *)arg,
> > -                                 sizeof(record_id));
> > -             if (rc)
> > +             if (copy_from_user(&record_id, (void __user *)arg,
> > +                                sizeof(record_id)))
> >                       return -EFAULT;
> >               return erst_clear(record_id);
> >       case APEI_ERST_GET_RECORD_COUNT:
> > @@ -175,8 +174,7 @@ static ssize_t erst_dbg_write(struct file *filp, const char __user *ubuf,
> >               erst_dbg_buf = p;
> >               erst_dbg_buf_len = usize;
> >       }
> > -     rc = copy_from_user(erst_dbg_buf, ubuf, usize);
> > -     if (rc) {
> > +     if (copy_from_user(erst_dbg_buf, ubuf, usize)) {
> >               rc = -EFAULT;
> >               goto out;
> >       }
>
> Hi Thorsten,
> Thanks for the patch.
>
> The changes look good to me.
>
> Since this is a code cleanup with no functional changes, could you
> please mention "no functional change" or similar wording in the commit
> message to make it clear?

Added.

> With that addressed:
> Reviewed-by: Shuai Xue <xueshuai@linux.alibaba.com>

And patch applied as 6.18 material, thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-15 19:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-03 22:49 [PATCH] ACPI: APEI: Remove redundant assignments in erst_dbg_{ioctl|write}() Thorsten Blum
2025-09-05  1:19 ` Shuai Xue
2025-09-15 19:22   ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®