media: vivid: fix error handling of kthread_run
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Mon, 29 Oct 2018 10:15:31 +0000 (06:15 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Fri, 23 Nov 2018 11:06:03 +0000 (06:06 -0500)
kthread_run returns an error pointer, but elsewhere in the code
dev->kthread_vid_cap/out is checked against NULL.

If kthread_run returns an error, then set the pointer to NULL.

I chose this method over changing all kthread_vid_cap/out tests
elsewhere since this is more robust.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reported-by: syzbot+53d5b2df0d9744411e2e@syzkaller.appspotmail.com
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/platform/vivid/vivid-kthread-cap.c
drivers/media/platform/vivid/vivid-kthread-out.c

index eebfff2126be22f0f50664322a722cefa2616a44..46e46e34a9e5f8cb9edbb34af3eddcd21d2c0d53 100644 (file)
@@ -873,8 +873,11 @@ int vivid_start_generating_vid_cap(struct vivid_dev *dev, bool *pstreaming)
                        "%s-vid-cap", dev->v4l2_dev.name);
 
        if (IS_ERR(dev->kthread_vid_cap)) {
+               int err = PTR_ERR(dev->kthread_vid_cap);
+
+               dev->kthread_vid_cap = NULL;
                v4l2_err(&dev->v4l2_dev, "kernel_thread() failed\n");
-               return PTR_ERR(dev->kthread_vid_cap);
+               return err;
        }
        *pstreaming = true;
        vivid_grab_controls(dev, true);
index 5a14810eeb6910a6ff6766aae181494ea9fc2e35..ce5bcda2348c97d4ab6b21ad72faaf6deee2e865 100644 (file)
@@ -244,8 +244,11 @@ int vivid_start_generating_vid_out(struct vivid_dev *dev, bool *pstreaming)
                        "%s-vid-out", dev->v4l2_dev.name);
 
        if (IS_ERR(dev->kthread_vid_out)) {
+               int err = PTR_ERR(dev->kthread_vid_out);
+
+               dev->kthread_vid_out = NULL;
                v4l2_err(&dev->v4l2_dev, "kernel_thread() failed\n");
-               return PTR_ERR(dev->kthread_vid_out);
+               return err;
        }
        *pstreaming = true;
        vivid_grab_controls(dev, true);