media: uvcvideo: Fix driver reference counting
authorPhilipp Zabel <philipp.zabel@gmail.com>
Mon, 21 May 2018 10:24:58 +0000 (06:24 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 4 Nov 2018 13:52:47 +0000 (14:52 +0100)
commite75194d294421704baf4c577e504cb9c92ec7ce2
tree131da2e4ba4c3220d0fd931f98be33e1aebc76c2
parentcdb44bdafc3a846aa785102f65a26762fbe32037
media: uvcvideo: Fix driver reference counting

commit f9ffcb0a21e1fa8e64d09ed613d884e054ae8191 upstream

kref_init initializes the reference count to 1, not 0. This additional
reference is never released since the conversion to reference counters.
As a result, uvc_delete is not called anymore when UVC cameras are
disconnected.
Fix this by adding an additional kref_put in uvc_disconnect and in the
probe error path. This also allows to remove the temporary additional
reference in uvc_unregister_video.

Fixes: 9d15cd958c17 ("media: uvcvideo: Convert from using an atomic variable to a reference count")

Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/usb/uvc/uvc_driver.c