Skip to contentSkip to conversation

video: fbdev: pxafb: zero allocated memory for video modes

PATCH Superseded Daniel Mack 1 participant 2 messages Jun 19, 2018 Framebuffer layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 video: fbdev: pxafb: zero allocated memory for video modes

When parsing the video modes from DT properties, make sure to zero out memory befor using it. This is important because not all fields in the mode struct are explicitly initialized, even though they are used later on.

Fixes 420a488278e86 (video: fbdev: pxafb: initial devicetree conversion)
Cc Robert Jarzmik <[email protected]>
---
 drivers/video/fbdev/pxafb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/video/fbdev/pxafb.c +2 -1
index c2c2e2790079..64926c95d06c 100644
@@ -2131,7 +2131,8 @@ static int of_get_pxafb_display(struct device *dev, struct device_node *disp,
 
 	ret = -ENOMEM;
 	info->modes = kmalloc_array(timings->num_timings,
-				    sizeof(info->modes[0]), GFP_KERNEL);
+				    sizeof(info->modes[0]),
+				    GFP_KERNEL | __GFP_ZERO);
 	if (!info->modes)
 		goto out;
 	info->num_modes = timings->num_timings;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 16 lines · Daniel Mack

When parsing the video modes from DT properties, make sure to zero out memory befor using it. This is important because not all fields in the mode struct are explicitly initialized, even though they are used later on.

Fixes 420a488278e86 (video: fbdev: pxafb: initial devicetree conversion)
Cc Robert Jarzmik <[email protected]>
---
  drivers/video/fbdev/pxafb.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/video/fbdev/pxafb.c +0 -0
index c2c2e2790079..64926c95d06c 100644

drivers/video/fbdev/pxafb.c static int of_get_pxafb_display(struct device *dev, struct device_node *disp, · line 2135

Quoted 6 lines
drivers/video/fbdev/pxafb.c +2 -1
@@ -2131,7 +2131,8 @@ static int of_get_pxafb_display(struct device *dev, struct device_node *disp,
 
  	ret = -ENOMEM;
  	info->modes = kmalloc_array(timings->num_timings,
-				    sizeof(info->modes[0]), GFP_KERNEL);
+				    sizeof(info->modes[0]),
+				    GFP_KERNEL | __GFP_ZERO);

Ah, kcalloc() is actually nicer. I'll send a v2.