Skip to content

Commit b0576ad

Browse files
JiangJiasgregkh
authored andcommitted
nvmem: brcm_nvram: Add check for kzalloc
Add the check for the return value of kzalloc in order to avoid NULL pointer dereference. Fixes: 6e977ea ("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]>
1 parent 2241ab5 commit b0576ad

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/nvmem/brcm_nvram.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ static int brcm_nvram_parse(struct brcm_nvram *priv)
9898
len = le32_to_cpu(header.len);
9999

100100
data = kzalloc(len, GFP_KERNEL);
101+
if (!data)
102+
return -ENOMEM;
103+
101104
memcpy_fromio(data, priv->base, len);
102105
data[len - 1] = '\0';
103106

0 commit comments

Comments
 (0)