drm/gma500: fix potential NULL pointer dereference dereference
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Sat, 12 Aug 2017 01:55:15 +0000 (20:55 -0500)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 18 Aug 2017 07:10:46 +0000 (09:10 +0200)
NULL check at line 528: if (!sender || !data_out || !len_out) {, implies
that pointer _sender_ might be NULL.

Move pointer _sender_ dereference after NULL check in order to avoid a
potential NULL pointer dereference.

This issue was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20170812015515.GA8360@embeddedgus
drivers/gpu/drm/gma500/mdfld_dsi_pkg_sender.c

index 1616af209bfcf89f9890b2d7a52a19c677f2802d..c50534c923df66014e26e7a634a45aa43d06be5e 100644 (file)
@@ -520,7 +520,7 @@ static int __read_panel_data(struct mdfld_dsi_pkg_sender *sender, u8 data_type,
                        u8 *data, u16 len, u32 *data_out, u16 len_out, bool hs)
 {
        unsigned long flags;
-       struct drm_device *dev = sender->dev;
+       struct drm_device *dev;
        int i;
        u32 gen_data_reg;
        int retry = MDFLD_DSI_READ_MAX_COUNT;
@@ -530,6 +530,8 @@ static int __read_panel_data(struct mdfld_dsi_pkg_sender *sender, u8 data_type,
                return -EINVAL;
        }
 
+       dev = sender->dev;
+
        /**
         * do reading.
         * 0) send out generic read request