Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp990424rwi; Wed, 19 Oct 2022 05:33:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6eK+dEY6PbtWr1Cc0I5G58MJV8Yg0QkqgX+3nUVsDSKjBPIaKrJVS2aCnvYTSO4AsgcbaR X-Received: by 2002:aa7:d454:0:b0:459:9ae7:725b with SMTP id q20-20020aa7d454000000b004599ae7725bmr7247371edr.165.1666182803818; Wed, 19 Oct 2022 05:33:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666182803; cv=none; d=google.com; s=arc-20160816; b=y0u81Ga9uax2O79XKo/oiww8SOvZ8cMs7ULYLZSnT3nYMxvfyXjFoX+/Q4bPD5FI0r IjJkUR67ENWJravBOm5ej6/kLCOdHKaICmXWG8ycfR+9/01MPcyPb11A+iMAv2Lf7JH0 /hYViuollfY5FrK7+JhMlAkWLvSmWncpDdMLw9T/IK7dNJ6YN+CuiNDIyFdgnW0W7Tc/ xjncc3dmfFPvwhxbvxPZyRFrNyIu6dspFWO+zPPQPCC6LdCpLs68qaKGF7fOFh+GYLWC tjyzSp8k20INpKP0y9cjItLujgIyQq1EKSxxPw9/CExdH8YUd9u766LSyuI1/ChhSEzi 4Orw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nVu0YmmNoBMP8YeraxqFTCj9C+CF9e5vTfj9QcuVnBM=; b=QDzDrrnFJTy5yPXcNHf48LLAAHvOaOc2nWSOQ3v7tES57j4Bf5lSpbpskyAzIyd/ff wvFvDTERx2NO9mgaiFpXDAruPlQ6+27ifJacr1Q8uZul9/VaqsqBUScu82uhNYVOCuQj iPs9b/I6brJ2yX02423txeAXj5D4llsXxmVnPf40P8vFkM46rZf7BfvY4qi8o5CyI6n5 5nWeuhrjJri4DFt3vL4ZEy1st4u8jLDeC79kDDO2cIQW0u9ULh2NwN7Tj3iKgOmn8qLV x2iaIwAkoQfrQNaLiWztUiXN6a3IHBzZZqbd6kYZFsmv5zirpj/Fo6CfzFw7YC4NTuU4 UH+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=d7MRcJF+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t25-20020a1709064f1900b00783d969f337si11386901eju.307.2022.10.19.05.32.56; Wed, 19 Oct 2022 05:33:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=d7MRcJF+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230030AbiJSMUZ (ORCPT + 99 others); Wed, 19 Oct 2022 08:20:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233213AbiJSMTK (ORCPT ); Wed, 19 Oct 2022 08:19:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5FEF1D679; Wed, 19 Oct 2022 04:54:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 982D6B82468; Wed, 19 Oct 2022 09:03:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7D41C433D6; Wed, 19 Oct 2022 09:02:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170180; bh=vsC+cg4HPLsC+F2/XwsJv30mCC9+RhZxAHJVrJ++TDg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d7MRcJF+juIjn5mdz4wynuoyeFa90P8fuAvzDnx1ybFlWwmNEDL2h8O8k+93xPGXP V1Hl+eZU40ludm//Ep3SRmM9hlaAziFTneaZpf9KwT3dkQS1T/JYgyQQhRKHuj3U29 blIsxGtedqam7KoomDBlgoFBvvb83VM5NnOvRRwM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Sasha Levin Subject: [PATCH 6.0 556/862] usb: dwc3: core: fix some leaks in probe Date: Wed, 19 Oct 2022 10:30:43 +0200 Message-Id: <20221019083314.546151210@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit 2a735e4b5580a2a6bbd6572109b4c4f163c57462 ] The dwc3_get_properties() function calls: dwc->usb_psy = power_supply_get_by_name(usb_psy_name); so there is some additional clean up required on these error paths. Fixes: 6f0764b5adea ("usb: dwc3: add a power supply for current control") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/YyxFYFnP53j9sCg+@kili Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/dwc3/core.c | 58 +++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 219d797e2230..919d36fd0298 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -1712,8 +1712,10 @@ static int dwc3_probe(struct platform_device *pdev) dwc3_get_properties(dwc); dwc->reset = devm_reset_control_array_get_optional_shared(dev); - if (IS_ERR(dwc->reset)) - return PTR_ERR(dwc->reset); + if (IS_ERR(dwc->reset)) { + ret = PTR_ERR(dwc->reset); + goto put_usb_psy; + } if (dev->of_node) { /* @@ -1723,45 +1725,57 @@ static int dwc3_probe(struct platform_device *pdev) * check for them to retain backwards compatibility. */ dwc->bus_clk = devm_clk_get_optional(dev, "bus_early"); - if (IS_ERR(dwc->bus_clk)) - return dev_err_probe(dev, PTR_ERR(dwc->bus_clk), - "could not get bus clock\n"); + if (IS_ERR(dwc->bus_clk)) { + ret = dev_err_probe(dev, PTR_ERR(dwc->bus_clk), + "could not get bus clock\n"); + goto put_usb_psy; + } if (dwc->bus_clk == NULL) { dwc->bus_clk = devm_clk_get_optional(dev, "bus_clk"); - if (IS_ERR(dwc->bus_clk)) - return dev_err_probe(dev, PTR_ERR(dwc->bus_clk), - "could not get bus clock\n"); + if (IS_ERR(dwc->bus_clk)) { + ret = dev_err_probe(dev, PTR_ERR(dwc->bus_clk), + "could not get bus clock\n"); + goto put_usb_psy; + } } dwc->ref_clk = devm_clk_get_optional(dev, "ref"); - if (IS_ERR(dwc->ref_clk)) - return dev_err_probe(dev, PTR_ERR(dwc->ref_clk), - "could not get ref clock\n"); + if (IS_ERR(dwc->ref_clk)) { + ret = dev_err_probe(dev, PTR_ERR(dwc->ref_clk), + "could not get ref clock\n"); + goto put_usb_psy; + } if (dwc->ref_clk == NULL) { dwc->ref_clk = devm_clk_get_optional(dev, "ref_clk"); - if (IS_ERR(dwc->ref_clk)) - return dev_err_probe(dev, PTR_ERR(dwc->ref_clk), - "could not get ref clock\n"); + if (IS_ERR(dwc->ref_clk)) { + ret = dev_err_probe(dev, PTR_ERR(dwc->ref_clk), + "could not get ref clock\n"); + goto put_usb_psy; + } } dwc->susp_clk = devm_clk_get_optional(dev, "suspend"); - if (IS_ERR(dwc->susp_clk)) - return dev_err_probe(dev, PTR_ERR(dwc->susp_clk), - "could not get suspend clock\n"); + if (IS_ERR(dwc->susp_clk)) { + ret = dev_err_probe(dev, PTR_ERR(dwc->susp_clk), + "could not get suspend clock\n"); + goto put_usb_psy; + } if (dwc->susp_clk == NULL) { dwc->susp_clk = devm_clk_get_optional(dev, "suspend_clk"); - if (IS_ERR(dwc->susp_clk)) - return dev_err_probe(dev, PTR_ERR(dwc->susp_clk), - "could not get suspend clock\n"); + if (IS_ERR(dwc->susp_clk)) { + ret = dev_err_probe(dev, PTR_ERR(dwc->susp_clk), + "could not get suspend clock\n"); + goto put_usb_psy; + } } } ret = reset_control_deassert(dwc->reset); if (ret) - return ret; + goto put_usb_psy; ret = dwc3_clk_enable(dwc); if (ret) @@ -1861,7 +1875,7 @@ static int dwc3_probe(struct platform_device *pdev) dwc3_clk_disable(dwc); assert_reset: reset_control_assert(dwc->reset); - +put_usb_psy: if (dwc->usb_psy) power_supply_put(dwc->usb_psy); -- 2.35.1