]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
usb: roles: fix NULL pointer issue when put module's reference
authorXu Yang <xu.yang_2@nxp.com>
Mon, 29 Jan 2024 09:37:38 +0000 (17:37 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Mar 2024 12:35:02 +0000 (13:35 +0100)
commit4b45829440b1b208948b39cc71f77a37a2536734
treefb7a2a82665f541e84381abdb507e3dffee7ddaf
parentda7fc10bc4714902c26d07261391f57cfa7c406d
usb: roles: fix NULL pointer issue when put module's reference

commit 1c9be13846c0b2abc2480602f8ef421360e1ad9e upstream.

In current design, usb role class driver will get usb_role_switch parent's
module reference after the user get usb_role_switch device and put the
reference after the user put the usb_role_switch device. However, the
parent device of usb_role_switch may be removed before the user put the
usb_role_switch. If so, then, NULL pointer issue will be met when the user
put the parent module's reference.

This will save the module pointer in structure of usb_role_switch. Then,
we don't need to find module by iterating long relations.

Fixes: 5c54fcac9a9d ("usb: roles: Take care of driver module reference counting")
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-1-xu.yang_2@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/roles/class.c