From: Marek Vasut <marek.vasut@gmail.com>
To: Arvind Yadav <arvind.yadav.cs@gmail.com>,
robert.jarzmik@free.fr, dwmw2@infradead.org,
computersforpeace@gmail.com, boris.brezillon@free-electrons.com,
richard@nod.at, cyrille.pitchen@atmel.com
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [V1] mtd: devices: docg3:- Handle return value of devm_ioremap.
Date: Sun, 11 Dec 2016 20:15:39 +0100 [thread overview]
Message-ID: <a09b8dbc-ca4b-000e-e5c2-5039119e99ba@gmail.com> (raw)
In-Reply-To: <1481479310-2698-1-git-send-email-arvind.yadav.cs@gmail.com>
On 12/11/2016 07:01 PM, Arvind Yadav wrote:
> Here, If devm_ioremap will fail. It will return NULL.
> Kernel can run into a NULL-pointer dereference.
>
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
> drivers/mtd/devices/docg3.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
> index b833e6c..013b5b9 100644
> --- a/drivers/mtd/devices/docg3.c
> +++ b/drivers/mtd/devices/docg3.c
> @@ -2083,9 +2083,12 @@ static int __init docg3_probe(struct platform_device *pdev)
> dev_err(dev, "No I/O memory resource defined\n");
> return ret;
> }
> - base = devm_ioremap(dev, ress->start, DOC_IOSPACE_SIZE);
>
> ret = -ENOMEM;
> + base = devm_ioremap(dev, ress->start, DOC_IOSPACE_SIZE);
> + if (!base)
> + return ret;
I think return -ENOMEM right away won't hurt here. Also, dev_err()
explaining the failure would be nice to add.
Thanks!
> cascade = devm_kzalloc(dev, sizeof(*cascade) * DOC_MAX_NBFLOORS,
> GFP_KERNEL);
> if (!cascade)
>
--
Best regards,
Marek Vasut
next prev parent reply other threads:[~2016-12-11 19:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-11 18:01 [V1] mtd: devices: docg3:- Handle return value of devm_ioremap Arvind Yadav
2016-12-11 19:15 ` Marek Vasut [this message]
2016-12-12 2:59 ` arvind Yadav
2016-12-12 18:19 ` Fabio Estevam
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=a09b8dbc-ca4b-000e-e5c2-5039119e99ba@gmail.com \
--to=marek.vasut@gmail.com \
--cc=arvind.yadav.cs@gmail.com \
--cc=boris.brezillon@free-electrons.com \
--cc=computersforpeace@gmail.com \
--cc=cyrille.pitchen@atmel.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--cc=robert.jarzmik@free.fr \
/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