diff mbox

[v1] video:fbdev:cobalt_lcdfb:- Handle return NULL error from devm_ioremap

Message ID 1481617252-8298-1-git-send-email-arvind.yadav.cs@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Arvind Yadav Dec. 13, 2016, 8:20 a.m. UTC
Here, If devm_ioremap will fail. It will return NULL.
Kernel can run into a NULL-pointer dereference.
This error check will avoid NULL pointer dereference.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/video/fbdev/cobalt_lcdfb.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Yoichi Yuasa Dec. 14, 2016, 2:23 a.m. UTC | #1
Hi Arvind,

Thank you for fixing it.

Acked-by: Yoichi Yuasa <yuasa@linux-mips.org>

2016-12-13 17:20 GMT+09:00 Arvind Yadav <arvind.yadav.cs@gmail.com>:
> Here, If devm_ioremap will fail. It will return NULL.
> Kernel can run into a NULL-pointer dereference.
> This error check will avoid NULL pointer dereference.
>
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
>  drivers/video/fbdev/cobalt_lcdfb.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/video/fbdev/cobalt_lcdfb.c b/drivers/video/fbdev/cobalt_lcdfb.c
> index 2d3b691..038ac69 100644
> --- a/drivers/video/fbdev/cobalt_lcdfb.c
> +++ b/drivers/video/fbdev/cobalt_lcdfb.c
> @@ -308,6 +308,11 @@ static int cobalt_lcdfb_probe(struct platform_device *dev)
>         info->screen_size = resource_size(res);
>         info->screen_base = devm_ioremap(&dev->dev, res->start,
>                                          info->screen_size);
> +       if (!info->screen_base) {
> +               framebuffer_release(info);
> +               return -ENOMEM;
> +       }
> +
>         info->fbops = &cobalt_lcd_fbops;
>         info->fix = cobalt_lcdfb_fix;
>         info->fix.smem_start = res->start;
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bartlomiej Zolnierkiewicz Jan. 4, 2017, 12:41 p.m. UTC | #2
Hi,

On Wednesday, December 14, 2016 11:23:07 AM Yuasa Yoichi wrote:
> Hi Arvind,
> 
> Thank you for fixing it.
> 
> Acked-by: Yoichi Yuasa <yuasa@linux-mips.org>
> 
> 2016-12-13 17:20 GMT+09:00 Arvind Yadav <arvind.yadav.cs@gmail.com>:
> > Here, If devm_ioremap will fail. It will return NULL.
> > Kernel can run into a NULL-pointer dereference.
> > This error check will avoid NULL pointer dereference.
> >
> > Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>

Applied & queued for v4.10.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/video/fbdev/cobalt_lcdfb.c b/drivers/video/fbdev/cobalt_lcdfb.c
index 2d3b691..038ac69 100644
--- a/drivers/video/fbdev/cobalt_lcdfb.c
+++ b/drivers/video/fbdev/cobalt_lcdfb.c
@@ -308,6 +308,11 @@  static int cobalt_lcdfb_probe(struct platform_device *dev)
 	info->screen_size = resource_size(res);
 	info->screen_base = devm_ioremap(&dev->dev, res->start,
 					 info->screen_size);
+	if (!info->screen_base) {
+		framebuffer_release(info);
+		return -ENOMEM;
+	}
+
 	info->fbops = &cobalt_lcd_fbops;
 	info->fix = cobalt_lcdfb_fix;
 	info->fix.smem_start = res->start;