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 <jiasheng@iscas.ac.cn> Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20230614093733.36048-1-jiasheng@iscas.ac.cn
1 parent 48f2c68 commit d97038d

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

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)