mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 20:22:09 +00:00
powerpc/powernv: Add a null pointer check to scom_debug_init_one()
kasprintf() returns a pointer to dynamically allocated memory
which can be NULL upon failure.
Add a null pointer check, and release 'ent' to avoid memory leaks.
Fixes: bfd2f0d49a
("powerpc/powernv: Get rid of old scom_controller abstraction")
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231208085937.107210-1-chentao@kylinos.cn
This commit is contained in:
parent
f46c8a7526
commit
9a260f2dd8
@ -165,6 +165,11 @@ static int scom_debug_init_one(struct dentry *root, struct device_node *dn,
|
||||
ent->chip = chip;
|
||||
snprintf(ent->name, 16, "%08x", chip);
|
||||
ent->path.data = (void *)kasprintf(GFP_KERNEL, "%pOF", dn);
|
||||
if (!ent->path.data) {
|
||||
kfree(ent);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ent->path.size = strlen((char *)ent->path.data);
|
||||
|
||||
dir = debugfs_create_dir(ent->name, root);
|
||||
|
Loading…
Reference in New Issue
Block a user