Skip to content

Commit

Permalink
media: amphion: Set video drvdata before register video device
Browse files Browse the repository at this point in the history
The video drvdata should be set before the video device is registered,
otherwise video_drvdata() may return NULL in the open() file ops, and led
to oops.

Fixes: 3cd0845 ("media: amphion: add vpu v4l2 m2m support")
Cc: <stable@vger.kernel.org>
Signed-off-by: Ming Qian <ming.qian@nxp.com>
Reviewed-by: TaoJiang <tao.jiang_2@nxp.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
  • Loading branch information
mingqian-0 authored and Hans Verkuil committed Oct 12, 2024
1 parent d2b7ecc commit 8cbb1a7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/media/platform/amphion/vpu_v4l2.c
Original file line number Diff line number Diff line change
Expand Up @@ -841,14 +841,14 @@ int vpu_add_func(struct vpu_dev *vpu, struct vpu_func *func)
vfd->fops = vdec_get_fops();
vfd->ioctl_ops = vdec_get_ioctl_ops();
}
video_set_drvdata(vfd, vpu);

ret = video_register_device(vfd, VFL_TYPE_VIDEO, -1);
if (ret) {
video_device_release(vfd);
v4l2_m2m_release(func->m2m_dev);
return ret;
}
video_set_drvdata(vfd, vpu);
func->vfd = vfd;

ret = v4l2_m2m_register_media_controller(func->m2m_dev, func->vfd, func->function);
Expand Down

0 comments on commit 8cbb1a7

Please sign in to comment.