Skip to content

Commit d97038d

Browse files
JiangJiaskees
authored andcommitted
pstore/ram: Add check for kstrdup
Add check for the return value of kstrdup() and return the error if it fails in order to avoid NULL pointer dereference. Fixes: e163fdb ("pstore/ram: Regularize prz label allocation lifetime") Signed-off-by: Jiasheng Jiang <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 48f2c68 commit d97038d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/pstore/ram_core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,8 @@ struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
599599
raw_spin_lock_init(&prz->buffer_lock);
600600
prz->flags = flags;
601601
prz->label = kstrdup(label, GFP_KERNEL);
602+
if (!prz->label)
603+
goto err;
602604

603605
ret = persistent_ram_buffer_map(start, size, prz, memtype);
604606
if (ret)

0 commit comments

Comments
 (0)