From 654c3be71e8f70e1577b162646359ed0c1ae6558 Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Tue, 25 Oct 2016 16:53:00 -0600 Subject: [PATCH] jhd1313m1: fix potential reference of uninitialized memory Signed-off-by: Jon Trulson --- src/jhd1313m1/jhd1313m1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jhd1313m1/jhd1313m1.c b/src/jhd1313m1/jhd1313m1.c index c18c60e5..2ebc01fd 100644 --- a/src/jhd1313m1/jhd1313m1.c +++ b/src/jhd1313m1/jhd1313m1.c @@ -43,6 +43,8 @@ jhd1313m1_context jhd1313m1_init(int bus, int lcd_addr, int rgb_addr) if (!dev) return NULL; + memset((void *)dev, 0, sizeof(struct _jhd1313m1_context)); + // make sure MRAA is initialized int mraa_rv; if ((mraa_rv = mraa_init()) != MRAA_SUCCESS) @@ -52,8 +54,6 @@ jhd1313m1_context jhd1313m1_init(int bus, int lcd_addr, int rgb_addr) return NULL; } - memset((void *)dev, 0, sizeof(struct _jhd1313m1_context)); - // initialize the MRAA contexts if (!(dev->i2cLCD = mraa_i2c_init(bus)))