MLK-11918-2 video: mxc ipuv3 fb: Return err in ->fb_check_var if fbi_tmp is NULL
authorLiu Ying <Ying.Liu@freescale.com>
Mon, 30 Nov 2015 02:55:12 +0000 (10:55 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:49:19 +0000 (14:49 -0500)
It has to be successful to find a relevant background framebuffer for a
foreground framebuffer.  So, we should return error code if it happens
to fail.

This patch fixes the following issue reported by Coverity:
Dereference after null check (FORWARD_NULL)
var_deref_op: Dereferencing null pointer fbi_tmp.
if (fbi_tmp->var.vmode & FB_VMODE_INTERLACED)
var->vmode |= FB_VMODE_INTERLACED;
else
var->vmode &= ~FB_VMODE_INTERLACED;

Signed-off-by: Liu Ying <Ying.Liu@freescale.com>
drivers/video/fbdev/mxc/mxc_ipuv3_fb.c

index 9f71693..d3f4825 100644 (file)
@@ -1566,11 +1566,15 @@ static int mxcfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)
                bg_yres = var->yres;
 
                fbi_tmp = found_registered_fb(MEM_BG_SYNC, mxc_fbi->ipu_id);
-               if (fbi_tmp) {
-                       bg_xres = fbi_tmp->var.xres;
-                       bg_yres = fbi_tmp->var.yres;
+               if (!fbi_tmp) {
+                       dev_err(info->device,
+                               "cannot find background fb for overlay fb\n");
+                       return -EINVAL;
                }
 
+               bg_xres = fbi_tmp->var.xres;
+               bg_yres = fbi_tmp->var.yres;
+
                ipu_disp_get_window_pos(mxc_fbi->ipu, mxc_fbi->ipu_ch, &pos_x, &pos_y);
 
                if ((var->xres + pos_x) > bg_xres)