[media] solo6x10: fix potential null dereference
authorHans Verkuil <hverkuil@xs4all.nl>
Fri, 25 Jul 2014 11:19:54 +0000 (08:19 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Sun, 27 Jul 2014 21:24:16 +0000 (18:24 -0300)
drivers/media/pci/solo6x10/solo6x10-disp.c:221 solo_set_motion_block() error: potential null dereference
'buf'.  (kzalloc returns null)

Also propagate this error up the chain.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/pci/solo6x10/solo6x10-disp.c
drivers/media/pci/solo6x10/solo6x10-v4l2-enc.c

index ed88ab4455a55a5b9be052ad7c3ae51c9f9f35a1..5ea9cac03968ee6d1b87d17f129cc4a8d37c85dc 100644 (file)
@@ -216,6 +216,8 @@ int solo_set_motion_block(struct solo_dev *solo_dev, u8 ch,
        int ret = 0;
 
        buf = kzalloc(size, GFP_KERNEL);
+       if (buf == NULL)
+               return -ENOMEM;
        for (y = 0; y < SOLO_MOTION_SZ; y++) {
                for (x = 0; x < SOLO_MOTION_SZ; x++)
                        buf[x] = cpu_to_le16(thresholds[y * SOLO_MOTION_SZ + x]);
index 2e07b497a37c5da61ab043d81786927c973b0aba..28023f9f1dc7e53061bfc062710652ef4cdfbd66 100644 (file)
@@ -1137,11 +1137,13 @@ static int solo_s_ctrl(struct v4l2_ctrl *ctrl)
                solo_enc->motion_enabled = ctrl->val > V4L2_DETECT_MD_MODE_DISABLED;
                if (ctrl->val) {
                        if (solo_enc->motion_global)
-                               solo_set_motion_threshold(solo_dev, solo_enc->ch,
+                               err = solo_set_motion_threshold(solo_dev, solo_enc->ch,
                                        solo_enc->motion_thresh);
                        else
-                               solo_set_motion_block(solo_dev, solo_enc->ch,
+                               err = solo_set_motion_block(solo_dev, solo_enc->ch,
                                        solo_enc->md_thresholds->p_cur.p_u16);
+                       if (err)
+                               return err;
                }
                solo_motion_toggle(solo_enc, ctrl->val);
                return 0;
@@ -1152,8 +1154,7 @@ static int solo_s_ctrl(struct v4l2_ctrl *ctrl)
                break;
        case V4L2_CID_OSD_TEXT:
                strcpy(solo_enc->osd_text, ctrl->p_new.p_char);
-               err = solo_osd_print(solo_enc);
-               return err;
+               return solo_osd_print(solo_enc);
        default:
                return -EINVAL;
        }