info->priv is dereferenced before a valid value has been set leading to
a NULL pointer dereference in the probe function. Fix this.

Signed-off-by: Ahmad Fatoum <[email protected]>
---
Cc: [email protected]
Cc: [email protected]

Hi,

how did this ever work? Does the platform that you used this on not trap
on NULL-pointer dereference?

Cheers,
---
 drivers/video/ssd1307fb.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/video/ssd1307fb.c b/drivers/video/ssd1307fb.c
index 70077e43a879..83a561a3e1fc 100644
--- a/drivers/video/ssd1307fb.c
+++ b/drivers/video/ssd1307fb.c
@@ -405,8 +405,9 @@ static int ssd1307fb_probe(struct device_d *dev)
        }
 
        info = xzalloc(sizeof(struct fb_info));
+       par = xzalloc(sizeof(*par));
 
-       par = info->priv;
+       info->priv = par;
        par->info = info;
        par->client = client;
 
@@ -574,6 +575,7 @@ reset_oled_error:
        free(vmem);
 fb_alloc_error:
        regulator_disable(par->vbat);
+       free(par);
        free(info);
        return ret;
 }
-- 
2.25.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to