diff options
author | Jiasheng Jiang <[email protected]> | 2023-01-27 10:40:06 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <[email protected]> | 2023-01-28 14:36:28 +0100 |
commit | b0576ade3aaf24b376ea1a4406ae138e2a22b0c0 (patch) | |
tree | 50d23ff70fd5c0e5a1d29f9f61d037c0b774730f | |
parent | 2241ab53cbb5cdb08a6b2d4688feb13971058f65 (diff) |
nvmem: brcm_nvram: Add check for kzalloc
Add the check for the return value of kzalloc in order to avoid
NULL pointer dereference.
Fixes: 6e977eaa8280 ("nvmem: brcm_nvram: parse NVRAM content into NVMEM cells")
Cc: [email protected]
Signed-off-by: Jiasheng Jiang <[email protected]>
Signed-off-by: Srinivas Kandagatla <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r-- | drivers/nvmem/brcm_nvram.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/nvmem/brcm_nvram.c b/drivers/nvmem/brcm_nvram.c index 34130449f2d2..39aa27942f28 100644 --- a/drivers/nvmem/brcm_nvram.c +++ b/drivers/nvmem/brcm_nvram.c @@ -98,6 +98,9 @@ static int brcm_nvram_parse(struct brcm_nvram *priv) len = le32_to_cpu(header.len); data = kzalloc(len, GFP_KERNEL); + if (!data) + return -ENOMEM; + memcpy_fromio(data, priv->base, len); data[len - 1] = '\0'; |