[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210303192614.759729-1-bjorn.andersson@linaro.org>
Date: Wed, 3 Mar 2021 11:26:14 -0800
From: Bjorn Andersson <bjorn.andersson@...aro.org>
To: Felipe Balbi <balbi@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Ray Chi <raychi@...gle.com>
Cc: linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-arm-msm@...r.kernel.org
Subject: [PATCH] usb: dwc3: Flip condition guarding power_supply_put()
The condition guarding the power_supply_put() calls in error and
removal paths are backwards, resulting in a guaranteed NULL pointer
dereference if no power supply was acquired.
Fixes: 59fa3def35de ("usb: dwc3: add a power supply for current control")
Signed-off-by: Bjorn Andersson <bjorn.andersson@...aro.org>
---
drivers/usb/dwc3/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c
index d15f065849cd..94fdbe502ce9 100644
--- a/drivers/usb/dwc3/core.c
+++ b/drivers/usb/dwc3/core.c
@@ -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;
--
2.29.2
Powered by blists - more mailing lists