From ce57cc1269c580abfca5b79cb40243b01aac357c Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 27 May 2025 08:43:34 +0300 Subject: ACPI: APEI: EINJ: Clean up on error in einj_probe() Call acpi_put_table() before returning the error code. Fixes: e54b1dc1c4f0 ("ACPI: APEI: EINJ: Remove redundant calls to einj_get_available_error_type()") Signed-off-by: Dan Carpenter Link: https://patch.msgid.link/aDVRBok33LZhXcId@stanley.mountain Signed-off-by: Rafael J. Wysocki --- drivers/acpi/apei/einj-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/apei/einj-core.c b/drivers/acpi/apei/einj-core.c index ca3484dac5c4..fea11a35eea3 100644 --- a/drivers/acpi/apei/einj-core.c +++ b/drivers/acpi/apei/einj-core.c @@ -766,7 +766,7 @@ static int __init einj_probe(struct faux_device *fdev) rc = einj_get_available_error_type(&available_error_type); if (rc) - return rc; + goto err_put_table; rc = -ENOMEM; einj_debug_dir = debugfs_create_dir("einj", apei_get_debugfs_dir()); -- cgit v1.2.3 From 9375e5e3557bf98e9c293aa32a9d2985eed16b5e Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Tue, 27 May 2025 08:54:04 +0300 Subject: ACPI: MRRM: Silence error code static checker warning 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 Link: https://patch.msgid.link/aDVTfEm-Jch7FuHG@stanley.mountain Signed-off-by: Rafael J. Wysocki --- 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 26c1a4e6b6ec..47ea3ccc2142 100644 --- a/drivers/acpi/acpi_mrrm.c +++ b/drivers/acpi/acpi_mrrm.c @@ -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); -- cgit v1.2.3 From d0b29661a95bbf804b6fe9bdff1d8927206c9f38 Mon Sep 17 00:00:00 2001 From: Ahmed Salem Date: Thu, 29 May 2025 17:43:13 +0200 Subject: ACPICA: Switch back to using strncpy() in acpi_ut_safe_strncpy() ACPICA commit b90d0d65ec97ff8279ad826f4102e0d31c5f662a I mistakenly replaced strncpy() with memcpy() in commit ebf27765421c ("ACPICA: Replace strncpy() with memcpy()"), not realizing the entire context behind *why* strncpy() was used. In this safer implementation of strncpy(), it does not make sense to use memcpy() only to null-terminate strings passed to acpi_ut_safe_strncpy() one byte early. The consequences of doing so are understandably *bad*, as was evident by the kernel test bot reporting problems [1]. Fixes: ebf27765421c ("ACPICA: Replace strncpy() with memcpy()") Link: https://lore.kernel.org/all/202505081033.50e45ff4-lkp@intel.com [1] Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202505081033.50e45ff4-lkp@intel.com Link: https://github.com/acpica/acpica/commit/b90d0d65 Signed-off-by: Ahmed Salem Signed-off-by: Rafael J. Wysocki Link: https://patch.msgid.link/12685690.O9o76ZdvQC@rjwysocki.net --- drivers/acpi/acpica/utnonansi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/acpica/utnonansi.c b/drivers/acpi/acpica/utnonansi.c index 803e3e893825..ff0802ace19b 100644 --- a/drivers/acpi/acpica/utnonansi.c +++ b/drivers/acpi/acpica/utnonansi.c @@ -168,7 +168,7 @@ void acpi_ut_safe_strncpy(char *dest, char *source, acpi_size dest_size) { /* Always terminate destination string */ - memcpy(dest, source, dest_size); + strncpy(dest, source, dest_size); dest[dest_size - 1] = 0; } -- cgit v1.2.3