Skip to content

Commit

Permalink
nvmem: brcm_nvram: Add check for kzalloc
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jiasheng Jiang authored and Greg Kroah-Hartman committed Jan 28, 2023
1 parent 2241ab5 commit b0576ad
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/nvmem/brcm_nvram.c
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit b0576ad

Please sign in to comment.