]> git.hungrycats.org Git - linux/commitdiff
media: amphion: Set video drvdata before register video device
authorMing Qian <ming.qian@nxp.com>
Fri, 13 Sep 2024 06:21:45 +0000 (15:21 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 9 Dec 2024 09:33:02 +0000 (10:33 +0100)
commit 8cbb1a7bd5973b57898b26eb804fe44af440bb63 upstream.

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: 3cd084519c6f ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/platform/amphion/vpu_v4l2.c

index d7e0de49b3dcef48e7b56c11f29e37d700d33800..61d27b63b99d47ab2d2d8082d74e9466ea407f5e 100644 (file)
@@ -825,6 +825,7 @@ 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) {
@@ -832,7 +833,6 @@ int vpu_add_func(struct vpu_dev *vpu, struct vpu_func *func)
                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);