]> Git Repo - linux.git/commitdiff
pstore/ram: Add check for kstrdup
authorJiasheng Jiang <[email protected]>
Wed, 14 Jun 2023 09:37:33 +0000 (17:37 +0800)
committerKees Cook <[email protected]>
Wed, 14 Jun 2023 18:52:10 +0000 (11:52 -0700)
Add check for the return value of kstrdup() and return the error
if it fails in order to avoid NULL pointer dereference.

Fixes: e163fdb3f7f8 ("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]
fs/pstore/ram_core.c

index 966191d3a5ba20fb9f5dadd6a07cccad8b1942eb..85aaf0fc6d7d1847631ccf4ef0f62ec2ee16f083 100644 (file)
@@ -599,6 +599,8 @@ struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size,
        raw_spin_lock_init(&prz->buffer_lock);
        prz->flags = flags;
        prz->label = kstrdup(label, GFP_KERNEL);
+       if (!prz->label)
+               goto err;
 
        ret = persistent_ram_buffer_map(start, size, prz, memtype);
        if (ret)
This page took 0.055172 seconds and 4 git commands to generate.