]> git.baikalelectronics.ru Git - kernel.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:03:30 +0000 (23:03 +0900)
commit6c4615df169f15efc4613da3196d379b498d64d3
tree326e5e6db51c530751f49ac3c40760b143baf78a
parentcf6c7d8878e61b8731e13a2085c6bfc0eaa11f4f
usb: gadget: tegra-xudc: Fix crash in vbus_draw

[ Upstream commit 5629d31955297ca47b9283c64fff70f2f34aa528 ]

Commit 2ecb9be801e0 ("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: 2ecb9be801e0 ("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