linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] video : fbdev : stifb :- Handle return NULL error from ioremap_nocache.
@ 2017-01-18 10:33 ` Arvind Yadav
  2017-01-30 15:59   ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 2+ messages in thread
From: Arvind Yadav @ 2017-01-18 10:33 UTC (permalink / raw)
  To: jejb, deller, b.zolnierkie; +Cc: linux-parisc, linux-fbdev, linux-kernel

Here, If ioremap_nocache 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/stifb.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/video/fbdev/stifb.c b/drivers/video/fbdev/stifb.c
index accfef7..d5deab3 100644
--- a/drivers/video/fbdev/stifb.c
+++ b/drivers/video/fbdev/stifb.c
@@ -1294,6 +1294,10 @@ static int __init stifb_init_fb(struct sti_struct *sti, int bpp_pref)
 	strcpy(fix->id, "stifb");
 	info->fbops = &stifb_ops;
 	info->screen_base = ioremap_nocache(REGION_BASE(fb,1), fix->smem_len);
+	if (!info->screen_base) {
+		printk(KERN_ERR "stifb: Failed to Map memory\n");
+		goto out_err0;
+	}
 	info->screen_size = fix->smem_len;
 	info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA;
 	info->pseudo_palette = &fb->pseudo_palette;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] video : fbdev : stifb :- Handle return NULL error from ioremap_nocache.
  2017-01-18 10:33 ` [PATCH v1] video : fbdev : stifb :- Handle return NULL error from ioremap_nocache Arvind Yadav
@ 2017-01-30 15:59   ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 2+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2017-01-30 15:59 UTC (permalink / raw)
  To: Arvind Yadav; +Cc: jejb, deller, linux-parisc, linux-fbdev, linux-kernel


Hi,

On Wednesday, January 18, 2017 03:51:51 PM Arvind Yadav wrote:
> Here, If ioremap_nocache 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>

Thanks, I queued your patch with some minor changes for 4.11
(you can see the final version of the patch below).

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


From: Arvind Yadav <arvind.yadav.cs@gmail.com>
Subject: [PATCH v1] video: fbdev: stifb: handle NULL return value from ioremap_nocache

Add missing error check for ioremap_nocache() failure
(prevents NULL pointer dereference on error).

Cc: "James E.J. Bottomley" <jejb@parisc-linux.org>
Cc: Helge Deller <deller@gmx.de>
Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
[b.zolnierkie: minor fixes]
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
---
 drivers/video/fbdev/stifb.c |    4 ++++
 1 file changed, 4 insertions(+)

Index: b/drivers/video/fbdev/stifb.c
=================================--- a/drivers/video/fbdev/stifb.c	2017-01-30 16:55:15.766435453 +0100
+++ b/drivers/video/fbdev/stifb.c	2017-01-30 16:55:15.750435453 +0100
@@ -1294,6 +1294,10 @@ static int __init stifb_init_fb(struct s
 	strcpy(fix->id, "stifb");
 	info->fbops = &stifb_ops;
 	info->screen_base = ioremap_nocache(REGION_BASE(fb,1), fix->smem_len);
+	if (!info->screen_base) {
+		printk(KERN_ERR "stifb: failed to map memory\n");
+		goto out_err0;
+	}
 	info->screen_size = fix->smem_len;
 	info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA;
 	info->pseudo_palette = &fb->pseudo_palette;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-30 15:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20170118102229epcas1p21c74a99299ee919a3f2d28ad435b7ca7@epcas1p2.samsung.com>
2017-01-18 10:33 ` [PATCH v1] video : fbdev : stifb :- Handle return NULL error from ioremap_nocache Arvind Yadav
2017-01-30 15:59   ` Bartlomiej Zolnierkiewicz

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).