From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
Cc: David Woodhouse <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>,
Marek Vasut <marek.vasut@gmail.com>,
Richard Weinberger <richard@nod.at>,
Cyrille Pitchen <cyrille.pitchen@wedev4u.fr>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mtd: spear_smi: add NULL check on devm_kzalloc() return value
Date: Mon, 17 Jul 2017 22:49:35 +0200 [thread overview]
Message-ID: <20170717224935.4dd40ba0@bbrezillon> (raw)
In-Reply-To: <20170706222550.GA30998@embeddedgus>
Le Thu, 6 Jul 2017 17:25:50 -0500,
"Gustavo A. R. Silva" <garsilva@embeddedor.com> a écrit :
> Check return value from call to devm_kzalloc()
> in order to prevent a NULL pointer dereference.
>
> This issue was detected using Coccinelle and the following semantic patch:
>
> @@
> expression x;
> identifier fld;
> @@
>
> * x = devm_kzalloc(...);
> ... when != x == NULL
> x->fld
>
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
> ---
> drivers/mtd/devices/spear_smi.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/mtd/devices/spear_smi.c b/drivers/mtd/devices/spear_smi.c
> index dd50698..ddf4789 100644
> --- a/drivers/mtd/devices/spear_smi.c
> +++ b/drivers/mtd/devices/spear_smi.c
> @@ -775,6 +775,8 @@ static int spear_smi_probe_config_dt(struct platform_device *pdev,
> pdata->board_flash_info = devm_kzalloc(&pdev->dev,
> sizeof(*pdata->board_flash_info),
> GFP_KERNEL);
> + if (!pdata->board_flash_info)
> + return -ENOMEM;
>
> /* Fill structs for each subnode (flash device) */
> while ((pp = of_get_next_child(np, pp))) {
next prev parent reply other threads:[~2017-07-17 20:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-06 22:25 [PATCH] mtd: spear_smi: add NULL check on devm_kzalloc() return value Gustavo A. R. Silva
2017-07-17 20:49 ` Boris Brezillon [this message]
2017-08-17 12:57 ` Boris Brezillon
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=20170717224935.4dd40ba0@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@wedev4u.fr \
--cc=dwmw2@infradead.org \
--cc=garsilva@embeddedor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=marek.vasut@gmail.com \
--cc=richard@nod.at \
/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;
as well as URLs for NNTP newsgroup(s).