Ver Fonte

media: i2c: ov5640: fix potential null pointer dereference

Found by klocworks:

384 (Local) drivers/media/i2c/ov5640.c:2591 NPD.FUNC.MUST
(1:Critical) Analyze
Pointer 'ctrls->pixel_rate' returned from call to function
'v4l2_ctrl_new_std' at line 2587 may be NULL and will be dereferenced
at line 2591.
  * ov5640.c:2588: 'ctrls->pixel_rate' is assigned the return value
		from function 'v4l2_ctrl_new_std'.
    * v4l2-ctrls.c:2290: 'v4l2_ctrl_new_std' explicitly returns a NULL
		value.
  * ov5640.c:2591: 'ctrls->pixel_rate' is explicitly dereferenced.

Signed-off-by: Benoit Parrot <bparrot@ti.com>
Benoit Parrot há 6 anos atrás
pai
commit
38fe27ccf9
1 ficheiros alterados com 1 adições e 1 exclusões
  1. 1 1
      drivers/media/i2c/ov5640.c

+ 1 - 1
drivers/media/i2c/ov5640.c

@@ -2588,7 +2588,6 @@ static int ov5640_init_controls(struct ov5640_dev *sensor)
 		v4l2_ctrl_new_std(hdl, ops,
 				  V4L2_CID_PIXEL_RATE, 0, INT_MAX, 1,
 				  55969920);
-	ctrls->pixel_rate->flags |= V4L2_CTRL_FLAG_READ_ONLY;
 
 	/* Auto/manual white balance */
 	ctrls->auto_wb = v4l2_ctrl_new_std(hdl, ops,
@@ -2637,6 +2636,7 @@ static int ov5640_init_controls(struct ov5640_dev *sensor)
 		goto free_ctrls;
 	}
 
+	ctrls->pixel_rate->flags |= V4L2_CTRL_FLAG_READ_ONLY;
 	ctrls->gain->flags |= V4L2_CTRL_FLAG_VOLATILE;
 	ctrls->exposure->flags |= V4L2_CTRL_FLAG_VOLATILE;