Commit 2ddf22ee authored by Benoit Parrot's avatar Benoit Parrot Committed by Mauro Carvalho Chehab

[media] media: ti-vpe: cal: Fix warning: variable dereference before being checked

As reported ctx->sensor is being dereferenced before being checked
in cal_get_external_info(). That being the case it was also checked
twice in multiple other location where v4l2_subdev_call is already
checking it so no need to explicitly check it again.
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarBenoit Parrot <bparrot@ti.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 7f67c587
...@@ -804,6 +804,9 @@ static int cal_get_external_info(struct cal_ctx *ctx) ...@@ -804,6 +804,9 @@ static int cal_get_external_info(struct cal_ctx *ctx)
{ {
struct v4l2_ctrl *ctrl; struct v4l2_ctrl *ctrl;
if (!ctx->sensor)
return -ENODEV;
ctrl = v4l2_ctrl_find(ctx->sensor->ctrl_handler, V4L2_CID_PIXEL_RATE); ctrl = v4l2_ctrl_find(ctx->sensor->ctrl_handler, V4L2_CID_PIXEL_RATE);
if (!ctrl) { if (!ctrl) {
ctx_err(ctx, "no pixel rate control in subdev: %s\n", ctx_err(ctx, "no pixel rate control in subdev: %s\n",
...@@ -950,9 +953,6 @@ static int __subdev_get_format(struct cal_ctx *ctx, ...@@ -950,9 +953,6 @@ static int __subdev_get_format(struct cal_ctx *ctx,
struct v4l2_mbus_framefmt *mbus_fmt = &sd_fmt.format; struct v4l2_mbus_framefmt *mbus_fmt = &sd_fmt.format;
int ret; int ret;
if (!ctx->sensor)
return -EINVAL;
sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
sd_fmt.pad = 0; sd_fmt.pad = 0;
...@@ -975,9 +975,6 @@ static int __subdev_set_format(struct cal_ctx *ctx, ...@@ -975,9 +975,6 @@ static int __subdev_set_format(struct cal_ctx *ctx,
struct v4l2_mbus_framefmt *mbus_fmt = &sd_fmt.format; struct v4l2_mbus_framefmt *mbus_fmt = &sd_fmt.format;
int ret; int ret;
if (!ctx->sensor)
return -EINVAL;
sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE; sd_fmt.which = V4L2_SUBDEV_FORMAT_ACTIVE;
sd_fmt.pad = 0; sd_fmt.pad = 0;
*mbus_fmt = *fmt; *mbus_fmt = *fmt;
...@@ -1152,7 +1149,7 @@ static int cal_enum_framesizes(struct file *file, void *fh, ...@@ -1152,7 +1149,7 @@ static int cal_enum_framesizes(struct file *file, void *fh,
ret = v4l2_subdev_call(ctx->sensor, pad, enum_frame_size, NULL, &fse); ret = v4l2_subdev_call(ctx->sensor, pad, enum_frame_size, NULL, &fse);
if (ret) if (ret)
return -EINVAL; return ret;
ctx_dbg(1, ctx, "%s: index: %d code: %x W:[%d,%d] H:[%d,%d]\n", ctx_dbg(1, ctx, "%s: index: %d code: %x W:[%d,%d] H:[%d,%d]\n",
__func__, fse.index, fse.code, fse.min_width, fse.max_width, __func__, fse.index, fse.code, fse.min_width, fse.max_width,
...@@ -1330,13 +1327,11 @@ static int cal_start_streaming(struct vb2_queue *vq, unsigned int count) ...@@ -1330,13 +1327,11 @@ static int cal_start_streaming(struct vb2_queue *vq, unsigned int count)
cal_wr_dma_addr(ctx, addr); cal_wr_dma_addr(ctx, addr);
csi2_ppi_enable(ctx); csi2_ppi_enable(ctx);
if (ctx->sensor) { ret = v4l2_subdev_call(ctx->sensor, video, s_stream, 1);
if (v4l2_subdev_call(ctx->sensor, video, s_stream, 1)) { if (ret) {
ctx_err(ctx, "stream on failed in subdev\n"); ctx_err(ctx, "stream on failed in subdev\n");
cal_runtime_put(ctx->dev); cal_runtime_put(ctx->dev);
ret = -EINVAL; goto err;
goto err;
}
} }
if (debug >= 4) if (debug >= 4)
...@@ -1359,10 +1354,8 @@ static void cal_stop_streaming(struct vb2_queue *vq) ...@@ -1359,10 +1354,8 @@ static void cal_stop_streaming(struct vb2_queue *vq)
struct cal_buffer *buf, *tmp; struct cal_buffer *buf, *tmp;
unsigned long flags; unsigned long flags;
if (ctx->sensor) { if (v4l2_subdev_call(ctx->sensor, video, s_stream, 0))
if (v4l2_subdev_call(ctx->sensor, video, s_stream, 0)) ctx_err(ctx, "stream off failed in subdev\n");
ctx_err(ctx, "stream off failed in subdev\n");
}
csi2_ppi_disable(ctx); csi2_ppi_disable(ctx);
disable_irqs(ctx); disable_irqs(ctx);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment