Skip to content

Commit

Permalink
media: s3c-camif: Avoid inappropriate kfree()
Browse files Browse the repository at this point in the history
[ Upstream commit 6133481 ]

s3c_camif_register_video_node() works with video_device structure stored
as a field of camif_vp, so it should not be kfreed.
But there is video_device_release() on error path that do it.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: babde1c ("[media] V4L: Add driver for S3C24XX/S3C64XX SoC series camera interface")
Signed-off-by: Katya Orlova <e.orlova@ispras.ru>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Katya Orlova authored and gregkh committed Nov 20, 2023
1 parent 2527ddd commit aa94287
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions drivers/media/platform/s3c-camif/camif-capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -1142,12 +1142,12 @@ int s3c_camif_register_video_node(struct camif_dev *camif, int idx)

ret = vb2_queue_init(q);
if (ret)
goto err_vd_rel;
return ret;

vp->pad.flags = MEDIA_PAD_FL_SINK;
ret = media_entity_pads_init(&vfd->entity, 1, &vp->pad);
if (ret)
goto err_vd_rel;
return ret;

video_set_drvdata(vfd, vp);

Expand Down Expand Up @@ -1179,8 +1179,6 @@ int s3c_camif_register_video_node(struct camif_dev *camif, int idx)
v4l2_ctrl_handler_free(&vp->ctrl_handler);
err_me_cleanup:
media_entity_cleanup(&vfd->entity);
err_vd_rel:
video_device_release(vfd);
return ret;
}

Expand Down

0 comments on commit aa94287

Please sign in to comment.