]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ACPI: MRRM: Silence error code static checker warning
authorDan Carpenter <dan.carpenter@linaro.org>
Tue, 27 May 2025 05:54:04 +0000 (08:54 +0300)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 27 May 2025 13:22:56 +0000 (15:22 +0200)
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>
Link: https://patch.msgid.link/aDVTfEm-Jch7FuHG@stanley.mountain
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/acpi_mrrm.c

index 26c1a4e6b6ec51c8c15b0391eebd5f489f6b67ff..47ea3ccc2142496a69a10b727afc3ae88bf4a2d8 100644 (file)
@@ -157,8 +157,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);