]> git.hungrycats.org Git - linux/commit
usb: roles: don't get/set_role() when usb_role_switch is unregistered
authorXu Yang <xu.yang_2@nxp.com>
Mon, 29 Jan 2024 09:37:39 +0000 (17:37 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Mar 2024 12:26:34 +0000 (13:26 +0100)
commit2f414a56b369129cfdac6ecaf9899f9807a264aa
tree1f306d6dc0d57f0e936e75d0be463d7c1085d70d
parent0158216805ca7e498d07de38840d2732166ae5fa
usb: roles: don't get/set_role() when usb_role_switch is unregistered

commit b787a3e781759026a6212736ef8e52cf83d1821a upstream.

There is a possibility that usb_role_switch device is unregistered before
the user put usb_role_switch. In this case, the user may still want to
get/set_role() since the user can't sense the changes of usb_role_switch.

This will add a flag to show if usb_role_switch is already registered and
avoid unwanted behaviors.

Fixes: fde0aa6c175a ("usb: common: Small class for USB role switches")
cc: stable@vger.kernel.org
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Link: https://lore.kernel.org/r/20240129093739.2371530-2-xu.yang_2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/roles/class.c