Skip to contentSkip to conversation

dsp_fbexport: use kzalloc

PATCH In review Arnaud Patard (Rtp) 2 participants 2 messages Nov 8, 2006 – Nov 9, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dsp_fbexport: use kzalloc

The dsp_export function calls omapfb_register_client() right after allocating the memory with kmalloc.
A commit added to omapfb_register_client() a check on the value of plane_idx in the notified block structure. As we're only using kmalloc, you may end-up comparing garbage/random values (It even leads to a oops on my n770).
Using kzalloc() fixes the issue.

---

---
arch/arm/plat-omap/dsp/dsp_mem.c | 2 1 + 1 - 0 !

 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/plat-omap/dsp/dsp_mem.c +1 -1
Index: linux-omap-2.6/arch/arm/plat-omap/dsp/dsp_mem.c
===================================================================
@@ -1495,7 +1495,7 @@ static int dsp_fbexport(dsp_long_t *dspa
 #endif
 
 #ifdef CONFIG_FB_OMAP_LCDC_EXTERNAL
-	omapfb_nb = kmalloc(sizeof(struct omapfb_notifier_block), GFP_KERNEL);
+	omapfb_nb = kzalloc(sizeof(struct omapfb_notifier_block), GFP_KERNEL);
 	if (omapfb_nb == NULL) {
 		printk(KERN_ERR
 		       "omapdsp: failed to allocate memory for omapfb_nb!\n");
#1 lore raw
Quoted 22 lines · Arnaud Patard

The dsp_export function calls omapfb_register_client() right after allocating the memory with kmalloc.
A commit added to omapfb_register_client() a check on the value of plane_idx in the notified block structure. As we're only using kmalloc, you may end-up comparing garbage/random values (It even leads to a oops on my n770).
Using kzalloc() fixes the issue.

---

---
arch/arm/plat-omap/dsp/dsp_mem.c | 2 1 + 1 - 0 !

 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-omap-2.6/arch/arm/plat-omap/dsp/dsp_mem.c
===================================================================

arch/arm/plat-omap/dsp/dsp_mem.c static int dsp_fbexport(dsp_long_t *dspa · line 1501

Quoted 8 lines
arch/arm/plat-omap/dsp/dsp_mem.c +1 -1
@@ -1495,7 +1495,7 @@ static int dsp_fbexport(dsp_long_t *dspa
 #endif
 
 #ifdef CONFIG_FB_OMAP_LCDC_EXTERNAL
-	omapfb_nb = kmalloc(sizeof(struct omapfb_notifier_block), GFP_KERNEL);
+	omapfb_nb = kzalloc(sizeof(struct omapfb_notifier_block), GFP_KERNEL);
 	if (omapfb_nb == NULL) {
 		printk(KERN_ERR
 		       "omapdsp: failed to allocate memory for omapfb_nb!\n");

Pushing today.

Tony