FROMGIT: usb: dwc3: Fix dereferencing of null dwc->usb_psy

Currently the null check logic on dwc->usb_psy is inverted as it allows
calls to power_supply_put with a null dwc->usb_psy causing a null
pointer dereference. Fix this by removing the ! operator.

Addresses-Coverity: ("Dereference after null check")
Fixes: 59fa3def35de ("usb: dwc3: add a power supply for current control")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20210303095826.6143-1-colin.king@canonical.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit d05a12f0478cbae41f26f62af767e86bd550ffb9
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I3c6183dc33f17affe0136db30151508785dd4e6e
This commit is contained in:
Colin Ian King 2021-03-03 09:58:26 +00:00 committed by Greg Kroah-Hartman
parent ab6e10de9d
commit af93035b6a

View File

@ -1628,7 +1628,7 @@ static int dwc3_probe(struct platform_device *pdev)
assert_reset:
reset_control_assert(dwc->reset);
if (!dwc->usb_psy)
if (dwc->usb_psy)
power_supply_put(dwc->usb_psy);
return ret;
@ -1653,7 +1653,7 @@ static int dwc3_remove(struct platform_device *pdev)
dwc3_free_event_buffers(dwc);
dwc3_free_scratch_buffers(dwc);
if (!dwc->usb_psy)
if (dwc->usb_psy)
power_supply_put(dwc->usb_psy);
return 0;