All of lore.kernel.org
 help / color / mirror / Atom feed
From: Colin Ian King <colin.king@canonical.com>
To: Heiko Thiery <heiko.thiery@gmail.com>, raychi@google.com
Cc: balbi@kernel.org, gregkh@linuxfoundation.org,
	kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: dwc3: Fix dereferencing of null dwc->usb_psy
Date: Wed, 3 Mar 2021 22:47:22 +0000	[thread overview]
Message-ID: <b93ff323-e03c-10b3-c38d-921bc6b2edc0@canonical.com> (raw)
In-Reply-To: <20210303212924.19733-1-heiko.thiery@gmail.com>

On 03/03/2021 21:29, Heiko Thiery wrote:
> Hi all,
> 
>> On Wed, Mar 3, 2021 at 6:00 PM Colin King <colin.king@canonical.com> wrote:
>>>
>>> From: Colin Ian King <colin.king@canonical.com>
>>>
>>> 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")
>>
>> Acked-by: Ray Chi <raychi@google.com>
>>
>>> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> 
> Tested-by: Heiko Thiery <heiko.thiery@gmail.com>

Thanks for testing. Much appreciated.

Colin
> 
>>> ---
>>>  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.30.0
>>>
> 
> Thank you.
> 


      reply	other threads:[~2021-03-04  0:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-03  9:58 [PATCH] usb: dwc3: Fix dereferencing of null dwc->usb_psy Colin King
2021-03-03 16:02 ` Ray Chi
2021-03-03 21:29   ` Heiko Thiery
2021-03-03 22:47     ` Colin Ian King [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b93ff323-e03c-10b3-c38d-921bc6b2edc0@canonical.com \
    --to=colin.king@canonical.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heiko.thiery@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=raychi@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.