media: v4l2-ioctl.c: fix incorrect error path
authorHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 18 May 2022 13:06:31 +0000 (14:06 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Tue, 27 Sep 2022 08:24:43 +0000 (10:24 +0200)
commitf0da34f32920c16f34acb692cf1646465bd40c04
tree4c72de99811873ca3f15401ae6fc8fe5e4d6217c
parent4e768c8e34e639cff66a0f175bc4aebf472e4305
media: v4l2-ioctl.c: fix incorrect error path

If allocating array_buf fails, or copying data from userspace into that
buffer fails, then just free memory and return the error. Don't attempt
to call video_put_user() since there is no point, and it would copy back
data on error even if INFO_FL_ALWAYS_COPY wasn't set.

So if writing the array back to userspace fails, then don't go to
out_array_args, instead just continue with the regular code that just
returns the error unless 'always_copy' is set.

Update the VIDIOC_G/S/TRY_EXT_CTRLS ioctls to set the ALWAYS_COPY flag
since they now need it. Before this worked due to this buggy code, but
now that that is fixed these ioctls need to set this flag explicitly.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/v4l2-core/v4l2-ioctl.c