Skip to contentSkip to conversation

ACPI, APEI: fix using the correct variable for sizeof()

PATCH Applied Jakob Koschel 2 participants 2 messages Mar 19, 2022 – Mar 22, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ACPI, APEI: fix using the correct variable for sizeof()

While the original code is valid, it is not the obvious choice for the sizeof() call and in preparation to limit the scope of the list iterator variable the sizeof should be changed to the size of the variable being allocated.

---
 drivers/acpi/apei/apei-base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/apei/apei-base.c +1 -1
index c7fdb12c3310..33b7fbbeda82 100644
@@ -319,7 +319,7 @@ static int apei_res_add(struct list_head *res_list,
 	if (res_ins)
 		list_add(&res_ins->list, res_list);
 	else {
-		res_ins = kmalloc(sizeof(*res), GFP_KERNEL);
+		res_ins = kmalloc(sizeof(*res_ins), GFP_KERNEL);
 		if (!res_ins)
 			return -ENOMEM;
 		res_ins->start = start;

base-commit: 34e047aa16c0123bbae8e2f6df33e5ecc1f56601

Signature · 1 line
2.25.1
maintainer Applied
#1 lore raw
Quoted 25 lines · Jakob Koschel

While the original code is valid, it is not the obvious choice for the sizeof() call and in preparation to limit the scope of the list iterator variable the sizeof should be changed to the size of the variable being allocated.

---
 drivers/acpi/apei/apei-base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/apei/apei-base.c +1 -1
index c7fdb12c3310..33b7fbbeda82 100644
@@ -319,7 +319,7 @@ static int apei_res_add(struct list_head *res_list,
        if (res_ins)
                list_add(&res_ins->list, res_list);
        else {
-               res_ins = kmalloc(sizeof(*res), GFP_KERNEL);
+               res_ins = kmalloc(sizeof(*res_ins), GFP_KERNEL);
                if (!res_ins)
                        return -ENOMEM;
                res_ins->start = start;
Quoted 2 lines

base-commit: 34e047aa16c0123bbae8e2f6df33e5ecc1f56601 --

Applied as 5.18-rc material, thanks!