From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D744C433E6 for ; Thu, 4 Mar 2021 00:22:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FAFD64DDA for ; Thu, 4 Mar 2021 00:22:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355269AbhCDAV5 (ORCPT ); Wed, 3 Mar 2021 19:21:57 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:52114 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1391720AbhCCWvS (ORCPT ); Wed, 3 Mar 2021 17:51:18 -0500 Received: from 1.general.cking.uk.vpn ([10.172.193.212]) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1lHaH5-0004Mx-2a; Wed, 03 Mar 2021 22:47:23 +0000 Subject: Re: [PATCH] usb: dwc3: Fix dereferencing of null dwc->usb_psy To: Heiko Thiery , 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 References: <20210303212924.19733-1-heiko.thiery@gmail.com> From: Colin Ian King Message-ID: Date: Wed, 3 Mar 2021 22:47:22 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <20210303212924.19733-1-heiko.thiery@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: kernel-janitors@vger.kernel.org On 03/03/2021 21:29, Heiko Thiery wrote: > Hi all, > >> On Wed, Mar 3, 2021 at 6:00 PM Colin King wrote: >>> >>> From: Colin Ian King >>> >>> 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 >> >>> Signed-off-by: Colin Ian King > > Tested-by: Heiko Thiery 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. >