* [PATCH] usb: dwc3: Flip condition guarding power_supply_put()
@ 2021-03-03 19:26 Bjorn Andersson
2021-03-04 8:21 ` Greg Kroah-Hartman
0 siblings, 1 reply; 2+ messages in thread
From: Bjorn Andersson @ 2021-03-03 19:26 UTC (permalink / raw)
To: Felipe Balbi, Greg Kroah-Hartman, Ray Chi
Cc: linux-usb, linux-kernel, linux-arm-msm
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@linaro.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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: dwc3: Flip condition guarding power_supply_put()
2021-03-03 19:26 [PATCH] usb: dwc3: Flip condition guarding power_supply_put() Bjorn Andersson
@ 2021-03-04 8:21 ` Greg Kroah-Hartman
0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2021-03-04 8:21 UTC (permalink / raw)
To: Bjorn Andersson
Cc: Felipe Balbi, Ray Chi, linux-usb, linux-kernel, linux-arm-msm
On Wed, Mar 03, 2021 at 11:26:14AM -0800, Bjorn Andersson wrote:
> 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@linaro.org>
> ---
> drivers/usb/dwc3/core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Already fixed:
d05a12f0478c ("usb: dwc3: Fix dereferencing of null dwc->usb_psy")
thanks,
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-04 8:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-03 19:26 [PATCH] usb: dwc3: Flip condition guarding power_supply_put() Bjorn Andersson
2021-03-04 8:21 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).