* [V1] mtd: devices: docg3:- Handle return value of devm_ioremap.
@ 2016-12-11 18:01 Arvind Yadav
2016-12-11 19:15 ` Marek Vasut
0 siblings, 1 reply; 4+ messages in thread
From: Arvind Yadav @ 2016-12-11 18:01 UTC (permalink / raw)
To: robert.jarzmik, dwmw2, computersforpeace, boris.brezillon,
marek.vasut, richard, cyrille.pitchen
Cc: linux-mtd, linux-kernel
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;
+
cascade = devm_kzalloc(dev, sizeof(*cascade) * DOC_MAX_NBFLOORS,
GFP_KERNEL);
if (!cascade)
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [V1] mtd: devices: docg3:- Handle return value of devm_ioremap.
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
2016-12-12 18:19 ` Fabio Estevam
0 siblings, 2 replies; 4+ messages in thread
From: Marek Vasut @ 2016-12-11 19:15 UTC (permalink / raw)
To: Arvind Yadav, robert.jarzmik, dwmw2, computersforpeace,
boris.brezillon, richard, cyrille.pitchen
Cc: linux-mtd, linux-kernel
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [V1] mtd: devices: docg3:- Handle return value of devm_ioremap.
2016-12-11 19:15 ` Marek Vasut
@ 2016-12-12 2:59 ` arvind Yadav
2016-12-12 18:19 ` Fabio Estevam
1 sibling, 0 replies; 4+ messages in thread
From: arvind Yadav @ 2016-12-12 2:59 UTC (permalink / raw)
To: Marek Vasut, robert.jarzmik, dwmw2, computersforpeace,
boris.brezillon, richard, cyrille.pitchen
Cc: linux-mtd, linux-kernel
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)
>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [V1] mtd: devices: docg3:- Handle return value of devm_ioremap.
2016-12-11 19:15 ` Marek Vasut
2016-12-12 2:59 ` arvind Yadav
@ 2016-12-12 18:19 ` Fabio Estevam
1 sibling, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2016-12-12 18:19 UTC (permalink / raw)
To: Marek Vasut
Cc: Arvind Yadav, Robert Jarzmik, David Woodhouse, Brian Norris,
Boris Brezillon, Richard Weinberger, Cyrille Pitchen, linux-mtd,
linux-kernel
On Sun, Dec 11, 2016 at 5:15 PM, Marek Vasut <marek.vasut@gmail.com> wrote:
>> 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.
There is no need to add dev_err() message as the mm core will complain
loudly if devm_ioremap() fails.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-12-12 18:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2016-12-12 18:19 ` Fabio Estevam
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).