提交 b0576ade 编写于 作者: J Jiasheng Jiang 提交者: Greg Kroah-Hartman

nvmem: brcm_nvram: Add check for kzalloc

Add the check for the return value of kzalloc in order to avoid
NULL pointer dereference.

Fixes: 6e977eaa ("nvmem: brcm_nvram: parse NVRAM content into NVMEM cells")
Cc: stable@vger.kernel.org
Signed-off-by: NJiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: NSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230127104015.23839-2-srinivas.kandagatla@linaro.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 2241ab53
...@@ -98,6 +98,9 @@ static int brcm_nvram_parse(struct brcm_nvram *priv) ...@@ -98,6 +98,9 @@ static int brcm_nvram_parse(struct brcm_nvram *priv)
len = le32_to_cpu(header.len); len = le32_to_cpu(header.len);
data = kzalloc(len, GFP_KERNEL); data = kzalloc(len, GFP_KERNEL);
if (!data)
return -ENOMEM;
memcpy_fromio(data, priv->base, len); memcpy_fromio(data, priv->base, len);
data[len - 1] = '\0'; data[len - 1] = '\0';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册