From: Joe Perches <joe@perches.com>
To: Dan Carpenter <dan.carpenter@oracle.com>, gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
"Rafał Miłecki" <rafal@milecki.pl>,
"Srinivas Kandagatla" <srinivas.kandagatla@linaro.org>
Subject: Re: [PATCH v3] nvmem: brcm_nvram: check for allocation failure
Date: Fri, 20 May 2022 00:59:12 -0700 [thread overview]
Message-ID: <ab048a2a99b7ff26da98ad01b575b036df7ddec9.camel@perches.com> (raw)
In-Reply-To: <20220520064516.GX4009@kadam>
On Fri, 2022-05-20 at 09:45 +0300, Dan Carpenter wrote:
> Check for if the kcalloc() fails.
>
> Cc: stable@vger.kernel.org
> Fixes: 6e977eaa8280 ("nvmem: brcm_nvram: parse NVRAM content into NVMEM cells")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> Acked-by: Rafał Miłecki <rafal@milecki.pl>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
> v3: Update fixes tag
> v2: I don't think anything changed in v2? Added tags?
[]
> diff --git 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;
trivia:
Not sure the kcalloc(1. ..) is useful.
It might be simpler using kzalloc, though given the memcpy_fromio
below a kcalloc/kzalloc seems dubious and kmalloc could be used.
> memcpy_fromio(data, priv->base, len);
> data[len - 1] = '\0';
>
prev parent reply other threads:[~2022-05-20 8:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-20 6:45 [PATCH v3] nvmem: brcm_nvram: check for allocation failure Dan Carpenter
2022-05-20 7:59 ` Joe Perches [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ab048a2a99b7ff26da98ad01b575b036df7ddec9.camel@perches.com \
--to=joe@perches.com \
--cc=dan.carpenter@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafal@milecki.pl \
--cc=srinivas.kandagatla@linaro.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox