Skip to content

Commit fbed1de

Browse files
author
Mamatha Inamdar
committed
powerpc/powernv: Add a null pointer check in opal_powercap_init()
JIRA: https://issues.redhat.com/browse/RHEL-37050 CVE: CVE-2023-52696 commit e123015 Author: Kunwu Chan <chentao@kylinos.cn> Date: Sun Nov 26 17:57:39 2023 +0800 powerpc/powernv: Add a null pointer check in opal_powercap_init() kasprintf() returns a pointer to dynamically allocated memory which can be NULL upon failure. Fixes: b9ef7b4 ("powerpc: Convert to using %pOFn instead of device_node.name") Signed-off-by: Kunwu Chan <chentao@kylinos.cn> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20231126095739.1501990-1-chentao@kylinos.cn Signed-off-by: Mamatha Inamdar <minamdar@redhat.com>
1 parent 6c1de86 commit fbed1de

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arch/powerpc/platforms/powernv/opal-powercap.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,12 @@ void __init opal_powercap_init(void)
196196

197197
j = 0;
198198
pcaps[i].pg.name = kasprintf(GFP_KERNEL, "%pOFn", node);
199+
if (!pcaps[i].pg.name) {
200+
kfree(pcaps[i].pattrs);
201+
kfree(pcaps[i].pg.attrs);
202+
goto out_pcaps_pattrs;
203+
}
204+
199205
if (has_min) {
200206
powercap_add_attr(min, "powercap-min",
201207
&pcaps[i].pattrs[j]);

0 commit comments

Comments
 (0)