atomisp: fix a possible null pointer dereference
authorMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 7 Sep 2012 11:43:02 +0000 (14:43 +0300)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Fri, 7 Sep 2012 11:44:56 +0000 (14:44 +0300)
Fix kernel oops in case isp->main_format is not initialized.

Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
drivers/media/video/atomisp/atomisp_cmd.c
drivers/media/video/atomisp/atomisp_ioctl.c

index f1718d0..ca1d507 100644 (file)
@@ -1323,6 +1323,7 @@ bool atomisp_is_viewfinder_support(struct atomisp_device *isp)
                return false;
 
        if ((isp->sw_contex.run_mode == CI_MODE_STILL_CAPTURE) &&
+           (isp->main_format) &&
            (isp->main_format->out_sh_fmt == SH_CSS_FRAME_FORMAT_RAW) &&
            (isp->sw_contex.bypass))
                return false;
index e8b884f..3219ba5 100644 (file)
@@ -790,7 +790,8 @@ int atomisp_reqbufs(struct file *file, void *fh,
 
        switch (isp->sw_contex.run_mode) {
        case CI_MODE_STILL_CAPTURE:
-               if (isp->main_format->out_sh_fmt != SH_CSS_FRAME_FORMAT_RAW) {
+               if ((isp->main_format) &&
+                   (isp->main_format->out_sh_fmt != SH_CSS_FRAME_FORMAT_RAW)) {
                        if (sh_css_capture_get_viewfinder_frame_info(&vf_info))
                                goto error;
                        if ((!isp->isp_subdev.video_out_vf.opened) &&
@@ -969,7 +970,8 @@ static int atomisp_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf)
 
                switch (isp->sw_contex.run_mode) {
                case CI_MODE_STILL_CAPTURE:
-                       if ((isp->main_format->out_sh_fmt !=
+                       if ((isp->main_format) &&
+                           (isp->main_format->out_sh_fmt !=
                                SH_CSS_FRAME_FORMAT_RAW) &&
                        sh_css_capture_get_viewfinder_frame_info(&vf_info))
                                goto error;