Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1177970pxb; Thu, 4 Mar 2021 05:28:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJz8sH82OqsIswKbi2hMt1ghdhGr37KPyu8mjkYwoIH5Q5X3J31Y08r0MpuURx01j5Cz+3Cf X-Received: by 2002:a05:6402:2695:: with SMTP id w21mr4333882edd.99.1614864536896; Thu, 04 Mar 2021 05:28:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614864536; cv=none; d=google.com; s=arc-20160816; b=bAK5SzPr0NtgCfHIedVi3SDsOKt0PlyvWUvABMl24OyX5lktLZBeHdiEpYdzQ8ibU8 WjORVyRtZpOPSltOyPYmopKZeIIcnG1DzbSd870xY2epMjZxva5QlLaOiHC4y6riEJyD SzZ8luxKn9dDm73LSnw+Ih5SaHpcP5wQCxomQUfJGPVatKtfpPPgqmSrp90UNGM1eOwh FlsdMxnoA+LLhOglYEBuATlQL9u4yGInpJys4/3ia80TnkzsImSVipDbRTTeK2fmQG0l 7uStunn39oyptrxhZpg/7er1l9upYNMFmZSIoRqGYs0RSJTSFTh3thbIbnNq/wp6PpyV h1CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=1Uei7v3ATOChAkkLQMcr1FQvIwwi3raldIF4smPmFCg=; b=0AThtxgX2rIOMzvfZHuwQaOMBojN6U6Udd7XEplsaorcUGv1cmoWQcWjAM7C7uJWhZ 1RR17DxXsurEe99JsmVRXWvjr0IGc3W/x5UgdKOuDFU0Fh1g97Oq4zRXCLF+T8hI/vJ8 PPKO4NGL2DQhQKywQ+uRlEoamv8y4H9mJzxmt891x1djMIkBFvPoGyrSpX0zs/2IeCvE 3hrnIKJmS3D7bohok04mGTmkJbt9KFnMKIutywLGL+DgS3jvvCrk31dm/ZoGbiVTx8VZ EzWO7bBMl9SDGw28HEKi4p1AirdPpBbECVKaECWQjrh8G0jCn2xgHxMl61rgMPo948HL WwzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k25si11499366ejq.186.2021.03.04.05.28.33; Thu, 04 Mar 2021 05:28:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378182AbhCDALe (ORCPT + 99 others); Wed, 3 Mar 2021 19:11:34 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:53484 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230527AbhCCX5t (ORCPT ); Wed, 3 Mar 2021 18:57:49 -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: linux-kernel@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. >