Skip to content

Commit 3f3da21

Browse files
committed
Merge: Add a null pointer check in opal powercap
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4274 Description: Add a null pointer check in opal powercap JIRA: https://issues.redhat.com/browse/RHEL-37050 CVE: CVE-2023-52696 Build Info: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=61354160 Tested: Verified Brew build test kernel RPMs Signed-off-by: Mamatha Inamdar <minamdar@redhat.com> 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> Approved-by: Steve Best <sbest@redhat.com> Approved-by: Tony Camuso <tcamuso@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Lucas Zampieri <lzampier@redhat.com>
2 parents 9445cbb + fbed1de commit 3f3da21

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)