lkml.org 
[lkml]   [2016]   [Dec]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [V2] mtd: devices: docg3:- Handle return value of devm_ioremap.
From
Date
On 12/12/2016 04:00 AM, 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 | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c
> index b833e6c..ffe3db0 100644
> --- a/drivers/mtd/devices/docg3.c
> +++ b/drivers/mtd/devices/docg3.c
> @@ -2083,9 +2083,14 @@ 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) {
> + dev_err(dev, "failed to map I/O memory\n");
> + return ret;

Um, return -ENOMEM right away ?

Otherwise,
Acked-by: Marek Vasut <marek.vasut@gmail.com>

> + }
> +
> cascade = devm_kzalloc(dev, sizeof(*cascade) * DOC_MAX_NBFLOORS,
> GFP_KERNEL);
> if (!cascade)
>


--
Best regards,
Marek Vasut

\
 
 \ /
  Last update: 2016-12-12 05:11    [W:0.057 / U:0.344 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site