]> git.baikalelectronics.ru Git - kernel.git/commit
USB: usb-skeleton: fix NULL-deref on disconnect
authorJohan Hovold <johan@kernel.org>
Wed, 9 Oct 2019 17:09:42 +0000 (19:09 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Oct 2019 10:41:18 +0000 (12:41 +0200)
commitbdc14225810e3926455c989ad6c82e7d24f7d869
tree5b6beb207aed9dc04a15c193f21da5e61d8c6c73
parent24ff94555448df3ddc2494efb964a4d1e44bb185
USB: usb-skeleton: fix NULL-deref on disconnect

The driver was using its struct usb_interface pointer as an inverted
disconnected flag and was setting it to NULL before making sure all
completion handlers had run. This could lead to NULL-pointer
dereferences in the dev_err() statements in the completion handlers
which relies on said pointer.

Fix this by using a dedicated disconnected flag.

Note that this is also addresses a NULL-pointer dereference at release()
and a struct usb_interface reference leak introduced by a recent runtime
PM fix, which depends on and should have been submitted together with
this patch.

Fixes: 02f6e7cea238 ("USB: usb-skeleton.c: remove err() usage")
Fixes: dd4b9666e501 ("USB: usb-skeleton: fix runtime PM after driver unbind")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20191009170944.30057-2-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/usb-skeleton.c