All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH next] ACPI: MRRM: Silence error code static checker warning
@ 2025-05-27  5:54 Dan Carpenter
  2025-05-27 13:24 ` Rafael J. Wysocki
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-05-27  5:54 UTC (permalink / raw)
  To: Tony Luck
  Cc: Rafael J. Wysocki, Len Brown, linux-acpi, linux-kernel,
	kernel-janitors

The error code is not set correctly on if kasprintf() fails.  On the
first iteration it would return -EINVAL and subsequent iterations
would return success.  Set it to -ENOMEM.

In real life, this allocation will not fail and if it did the system
will not boot so this change is mostly to silence static checker warnings
more than anything else.

Fixes: 04f53540f791 ("ACPI: MRRM: Add /sys files to describe memory ranges")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/acpi/acpi_mrrm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_mrrm.c b/drivers/acpi/acpi_mrrm.c
index 2f22f013959a..70088cdfde13 100644
--- a/drivers/acpi/acpi_mrrm.c
+++ b/drivers/acpi/acpi_mrrm.c
@@ -156,8 +156,10 @@ static __init int add_boot_memory_ranges(void)
 
 	for (int i = 0; i < mrrm_mem_entry_num; i++) {
 		name = kasprintf(GFP_KERNEL, "range%d", i);
-		if (!name)
+		if (!name) {
+			ret = -ENOMEM;
 			break;
+		}
 
 		kobj = kobject_create_and_add(name, pkobj);
 
-- 
2.47.2


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

* Re: [PATCH next] ACPI: MRRM: Silence error code static checker warning
  2025-05-27  5:54 [PATCH next] ACPI: MRRM: Silence error code static checker warning Dan Carpenter
@ 2025-05-27 13:24 ` Rafael J. Wysocki
  0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2025-05-27 13:24 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Tony Luck, Rafael J. Wysocki, Len Brown, linux-acpi, linux-kernel,
	kernel-janitors

On Tue, May 27, 2025 at 7:54 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> The error code is not set correctly on if kasprintf() fails.  On the
> first iteration it would return -EINVAL and subsequent iterations
> would return success.  Set it to -ENOMEM.
>
> In real life, this allocation will not fail and if it did the system
> will not boot so this change is mostly to silence static checker warnings
> more than anything else.
>
> Fixes: 04f53540f791 ("ACPI: MRRM: Add /sys files to describe memory ranges")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/acpi/acpi_mrrm.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/acpi/acpi_mrrm.c b/drivers/acpi/acpi_mrrm.c
> index 2f22f013959a..70088cdfde13 100644
> --- a/drivers/acpi/acpi_mrrm.c
> +++ b/drivers/acpi/acpi_mrrm.c
> @@ -156,8 +156,10 @@ static __init int add_boot_memory_ranges(void)
>
>         for (int i = 0; i < mrrm_mem_entry_num; i++) {
>                 name = kasprintf(GFP_KERNEL, "range%d", i);
> -               if (!name)
> +               if (!name) {
> +                       ret = -ENOMEM;
>                         break;
> +               }
>
>                 kobj = kobject_create_and_add(name, pkobj);
>
> --

Applied, thanks!

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

end of thread, other threads:[~2025-05-27 13:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-27  5:54 [PATCH next] ACPI: MRRM: Silence error code static checker warning Dan Carpenter
2025-05-27 13:24 ` Rafael J. Wysocki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.