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: stable@vger.kernel.org Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Link: https://lore.kernel.org/r/20230127104015.23839-2-srinivas.kandagatla@linaro.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2241ab5 commit b0576ad

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

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)