From: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Check for if the kcalloc() fails. Cc: stable@xxxxxxxxxxxxxxx Fixes: 299dc152721f ("nvmem: brcm_nvram: parse NVRAM content into NVMEM cells") Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Acked-by: Rafał Miłecki <rafal@xxxxxxxxxx> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@xxxxxxxxxx> --- Hi Greg, This is the only patch that was not applied cleanly to char-misc-testing due some fixes that are already applied on the same file. Rebased this and resending just this one. Thanks, --srini drivers/nvmem/brcm_nvram.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/nvmem/brcm_nvram.c b/drivers/nvmem/brcm_nvram.c index 450b927691c3..48bb8c62cbbf 100644 --- a/drivers/nvmem/brcm_nvram.c +++ b/drivers/nvmem/brcm_nvram.c @@ -97,6 +97,8 @@ static int brcm_nvram_parse(struct brcm_nvram *priv) len = le32_to_cpu(header.len); data = kcalloc(1, len, GFP_KERNEL); + if (!data) + return -ENOMEM; memcpy_fromio(data, priv->base, len); data[len - 1] = '\0'; -- 2.21.0