media: v4l2-compat-ioctl32.c: don't copy back the result for certain errors 88/175688/1
authorHans Verkuil <hans.verkuil@cisco.com>
Wed, 28 Mar 2018 18:12:32 +0000 (15:12 -0300)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 11 Apr 2018 11:56:52 +0000 (20:56 +0900)
commit d83a8243aaefe62ace433e4384a4f077bed86acb upstream.

Some ioctls need to copy back the result even if the ioctl returned
an error. However, don't do this for the error code -ENOTTY.
It makes no sense in that cases.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[sw0312.kim: cherry-pick from linux-3.18.y to apply CVE patch]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I1454b74c7f56e73bef2349528d68d15927fba359

drivers/media/v4l2-core/v4l2-compat-ioctl32.c

index d8a2c755cd8005b1dc3aa000594d25d566b705f2..b4fade8de4501bab264b141fb02f1e579ddec63d 100644 (file)
@@ -947,6 +947,9 @@ static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long ar
                set_fs(old_fs);
        }
 
+       if (err == -ENOTTY)
+               return err;
+
        /* Special case: even after an error we need to put the
           results back for these ioctls since the error_idx will
           contain information on which control failed. */