Skip to contentSkip to conversation

fbdev: remove unnecessary memset in vfb

PATCH In review Marcin Chojnacki 3 participants 4 messages Jun 18, 2015 – Aug 20, 2015 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fbdev: remove unnecessary memset in vfb

In vfb_probe memory is allocated using rvmalloc which automatically sets the allocated memory to zero. This patch removes the second unnecessary memset in vfb_probe.

---
 drivers/video/fbdev/vfb.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/video/fbdev/vfb.c +0 -8
index 70a897b..b2d38b7 100644
@@ -490,14 +490,6 @@ static int vfb_probe(struct platform_device *dev)
 	if (!(videomemory = rvmalloc(videomemorysize)))
 		return retval;
 
-	/*
-	 * VFB must clear memory to prevent kernel info
-	 * leakage into userspace
-	 * VGA-based drivers MUST NOT clear memory if
-	 * they want to be able to take over vgacon
-	 */
-	memset(videomemory, 0, videomemorysize);
-
 	info = framebuffer_alloc(sizeof(u32) * 256, &dev->dev);
 	if (!info)
 		goto err;
Signature · 1 line
2.1.4
#1 lore raw
Quoted 8 lines · Marcin Chojnacki

In vfb_probe memory is allocated using rvmalloc which automatically sets the allocated memory to zero. This patch removes the second unnecessary memset in vfb_probe.

---
 drivers/video/fbdev/vfb.c | 8 --------
 1 file changed, 8 deletions(-)

Thanks, queued for 4.3.

Tomi

#2 lore raw
In reply to Marcin Chojnacki
Quoted 15 lines · Marcin Chojnacki

In vfb_probe memory is allocated using rvmalloc which automatically sets the allocated memory to zero. This patch removes the second unnecessary memset in vfb_probe.

---
 drivers/video/fbdev/vfb.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/video/fbdev/vfb.c +0 -0
index 70a897b..b2d38b7 100644
@@ -490,14 +490,6 @@ static int vfb_probe(struct platform_device *dev)
        if (!(videomemory = rvmalloc(videomemorysize)))

drivers/video/fbdev/vfb.c static int vfb_probe(struct platform_device *dev) · line 500

Quoted 10 lines
drivers/video/fbdev/vfb.c +0 -8
                return retval;
 
-       /*
-        * VFB must clear memory to prevent kernel info
-        * leakage into userspace
-        * VGA-based drivers MUST NOT clear memory if
-        * they want to be able to take over vgacon
-        */
-       memset(videomemory, 0, videomemorysize);
-

As vfb also serves as a sample driver, I think it would be worthwhile to move the comment to rvmalloc().

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#3 lore raw
Quoted 18 lines · Geert Uytterhoeven
Quoted 17 lines · Marcin Chojnacki

In vfb_probe memory is allocated using rvmalloc which automatically sets the allocated memory to zero. This patch removes the second unnecessary memset in vfb_probe.

---
 drivers/video/fbdev/vfb.c | 8 --------
 1 file changed, 8 deletions(-)
drivers/video/fbdev/vfb.c +0 -0
index 70a897b..b2d38b7 100644
@@ -490,14 +490,6 @@ static int vfb_probe(struct platform_device *dev)
        if (!(videomemory = rvmalloc(videomemorysize)))
                return retval;
 
Quoted 11 lines

drivers/video/fbdev/vfb.c static int vfb_probe(struct platform_device *dev) · line 500

Quoted 8 lines
drivers/video/fbdev/vfb.c +0 -8
-       /*
-        * VFB must clear memory to prevent kernel info
-        * leakage into userspace
-        * VGA-based drivers MUST NOT clear memory if
-        * they want to be able to take over vgacon
-        */
-       memset(videomemory, 0, videomemorysize);
-

As vfb also serves as a sample driver, I think it would be worthwhile to move the comment to rvmalloc().

I changed the patch as follows:

commit c0a3229313d6931a77e0c1e1c22e398c0312bf6f

Author: Marcin Chojnacki <[email protected]>
Date:   Thu Jun 18 15:01:52 2015 +0200

fbdev: remove unnecessary memset in vfb

In vfb_probe memory is allocated using rvmalloc which automatically sets the allocated memory to zero. This patch removes the second unnecessary memset in vfb_probe.

drivers/video/fbdev/vfb.c +8 -9
index 70a897b1e458..b9c2f81fb6b9 100644
@@ -51,7 +51,14 @@ static void *rvmalloc(unsigned long size)
 	if (!mem)
 		return NULL;
 
-	memset(mem, 0, size); /* Clear the ram out, no junk to the user */
+	/*
+	 * VFB must clear memory to prevent kernel info
+	 * leakage into userspace
+	 * VGA-based drivers MUST NOT clear memory if
+	 * they want to be able to take over vgacon
+	 */
+
+	memset(mem, 0, size);
 	adr = (unsigned long) mem;
 	while (size > 0) {
 		SetPageReserved(vmalloc_to_page((void *)adr));
@@ -490,14 +497,6 @@ static int vfb_probe(struct platform_device *dev)
 	if (!(videomemory = rvmalloc(videomemorysize)))
 		return retval;
 
-	/*
-	 * VFB must clear memory to prevent kernel info
-	 * leakage into userspace
-	 * VGA-based drivers MUST NOT clear memory if
-	 * they want to be able to take over vgacon
-	 */
-	memset(videomemory, 0, videomemorysize);
-
 	info = framebuffer_alloc(sizeof(u32) * 256, &dev->dev);
 	if (!info)
 		goto err;