Skip to contentSkip to conversation

fbdev: Fix software blanking code

PATCH New Antonino A. Daplas 1 participant 1 message Oct 24, 2004 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fbdev: Fix software blanking code

The code in fbmem.c:fb_blank() is broken. For drivers without an fb_blank hook, an FBIO_BLANK ioctl will produce wrong colors or will segfault.

---
 fbmem.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
drivers/video/fbmem.c +6 -4
diff -Nru a/drivers/video/fbmem.c b/drivers/video/fbmem.c
@@ -750,18 +750,20 @@
 	
 	if (info->fbops->fb_blank && !info->fbops->fb_blank(blank, info))
 		return 0;
+
+	cmap = info->cmap;
+
 	if (blank) { 
 		black = kmalloc(sizeof(u16) * info->cmap.len, GFP_KERNEL);
-		if (!black) {
+		if (black) {
 			memset(black, 0, info->cmap.len * sizeof(u16));
 			cmap.red = cmap.green = cmap.blue = black;
 			cmap.transp = info->cmap.transp ? black : NULL;
 			cmap.start = info->cmap.start;
 			cmap.len = info->cmap.len;
 		}
-	} else
-		cmap = info->cmap;
-
+	}
+
 	err = fb_set_cmap(&cmap, info);
 	kfree(black);