]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
usb: gadget: tegra-xudc: Fix crash in vbus_draw
authorJon Hunter <jonathanh@nvidia.com>
Wed, 5 Apr 2023 18:18:53 +0000 (19:18 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2023 14:11:23 +0000 (23:11 +0900)
commit18571e1adb4a808627954a5a37919f35a428a537
tree5c2d7002215296a84de1f7e95ca23db9089d90b8
parent82699c827f5fcfd0db9c7d23a2fcc69a71fee6bf
usb: gadget: tegra-xudc: Fix crash in vbus_draw

[ Upstream commit 5629d31955297ca47b9283c64fff70f2f34aa528 ]

Commit ac82b56bda5f ("usb: gadget: tegra-xudc: Add vbus_draw support")
populated the vbus_draw callback for the Tegra XUDC driver. The function
tegra_xudc_gadget_vbus_draw(), that was added by this commit, assumes
that the pointer 'curr_usbphy' has been initialised, which is not always
the case because this is only initialised when the USB role is updated.
Fix this crash, by checking that the 'curr_usbphy' is valid before
dereferencing.

Fixes: ac82b56bda5f ("usb: gadget: tegra-xudc: Add vbus_draw support")
Reviewed-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Link: https://lore.kernel.org/r/20230405181854.42355-1-jonathanh@nvidia.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/gadget/udc/tegra-xudc.c