From: arvind Yadav <arvind.yadav.cs@gmail.com>
To: Marek Vasut <marek.vasut@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: Mon, 12 Dec 2016 08:29:19 +0530 [thread overview]
Message-ID: <ff59950b-de9e-a177-43ba-c543bf98df28@gmail.com> (raw)
In-Reply-To: <a09b8dbc-ca4b-000e-e5c2-5039119e99ba@gmail.com>
Yes, We are returning -ENOMEM, ret is initialized to -ENOMEM.
As per your concern, I have added dev_err failure message.
Thanks
-Arvind
On Monday 12 December 2016 12:45 AM, Marek Vasut wrote:
> 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)
>>
>
next prev parent reply other threads:[~2016-12-12 2:59 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
2016-12-12 2:59 ` arvind Yadav [this message]
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=ff59950b-de9e-a177-43ba-c543bf98df28@gmail.com \
--to=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=marek.vasut@gmail.com \
--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