]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
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)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1837477
commit 701f49bc028edb19ffccd101997dd84f0d71e279 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/media/platform/vivid/vivid-kthread-cap.c
drivers/media/platform/vivid/vivid-kthread-out.c

index 6ca71aabb57664182e4d80926bdf18a6778e7f11..d300e5e7eadc87f90d62de93cf46d1420be26b40 100644 (file)
@@ -877,8 +877,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 98eed5889bc17e96243a23b4e215460ff89169af..7c8d758528161d82013c60cffa0fa98c92b6cb07 100644 (file)
@@ -248,8 +248,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);