diff options
author | Jiasheng Jiang <jiasheng@iscas.ac.cn> | 2023-06-14 17:37:33 +0800 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2023-06-14 11:52:10 -0700 |
commit | d97038d5ec2062733c1e016caf9baaf68cf64ea1 (patch) | |
tree | 89c696e7b4c68787c04d1dd11dad059e358f588c /fs/pstore | |
parent | 48f2c681df4329b50fc92516c10e0398ca127242 (diff) |
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: e163fdb3f7f8 ("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
Diffstat (limited to 'fs/pstore')
-rw-r--r-- | fs/pstore/ram_core.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c index 966191d3a5ba..85aaf0fc6d7d 100644 --- a/fs/pstore/ram_core.c +++ b/fs/pstore/ram_core.c @@ -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) |