From patchwork Tue Dec 6 08:17:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaoqian Lin X-Patchwork-Id: 30136 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2695273wrr; Tue, 6 Dec 2022 00:22:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf6aGNS90HDD9n7KFLI6K/JzzWUiCu6FYjn99X8rXE7x8GeKYx4HqnZ77DZ+4MieHIc3oRs5 X-Received: by 2002:a17:90a:7649:b0:219:3e67:39dd with SMTP id s9-20020a17090a764900b002193e6739ddmr42732321pjl.156.1670314955749; Tue, 06 Dec 2022 00:22:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670314955; cv=none; d=google.com; s=arc-20160816; b=dsY+lFSQrjosHZtOQkOuJ1aqWwbjOzt83ePm5bJXJVyIERztOHTxksk8lwthI/4FgT PM0MyD2EHusAAhjYS+becVZ6S0mJCL4ZQGjul9Waw5ZLR5kIfQ8K54IXc7FuObPhS7LK beeh9pc/7jBGXaKji+oL9jjQCMbLpTx/RiGJJlePMxAB/p9uYYpXyQyisP6WmKO/8m/t F4JvzPNAIM6UFxRH94HnFxrgxbQ8QN2r45qr+u7eGWijs0wACZ7SyGmVz7qGnZrI1mtg xj+SQjEiaPxsEZiaZNvkEIuWyK+6lh9+ZMEE9jABoduHjbUGaR/4B/1v1gk9XH46C0TD G5gQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=TMi0rpjvwNLHZrVufPOOndRr3cEZbnUmp8cEObDhWWM=; b=E6AT99ocLoCa+qa/5vIMs2DDGuaFWr6ufetMebrkDPCaManCYbvoQDrgRVn0KrR/pb 9LzMMUzyQMaFwUsd10rGxKLW0f0kIGWI0kUYycoMEuzZ4Hlbl/rD4+5De6izSWbeYrr1 oPMm6A0vjedo6onvfZghuHDg7HkiprjkRHyQWeEyn/z4T8zfKnUT11iuawIsOQEObRFV T0RwIu7iEujqjngViqZKRvvGeilHIy3s/wx0fHidynwUlOei/sZ5Qv5KHeIbE546wTmW +ZtWb84NjQd0MkoDyAh99d3/q9OfgyQ7ma0pYd53svEAwn445oTkM/k1EngHDKyfwlYt iq+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=MqWQgLPr; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l13-20020a056a0016cd00b00569a7731a99si18297215pfc.326.2022.12.06.00.22.22; Tue, 06 Dec 2022 00:22:35 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=MqWQgLPr; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231527AbiLFITl (ORCPT + 99 others); Tue, 6 Dec 2022 03:19:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233991AbiLFIS4 (ORCPT ); Tue, 6 Dec 2022 03:18:56 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 423B86443; Tue, 6 Dec 2022 00:17:44 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id 3-20020a17090a098300b00219041dcbe9so14060061pjo.3; Tue, 06 Dec 2022 00:17:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=TMi0rpjvwNLHZrVufPOOndRr3cEZbnUmp8cEObDhWWM=; b=MqWQgLPrE9rbL8ey5VZ4aE4++1sgvurlqmmF4xQLG6eYhB/uZTPwDOiuYSOQN2Qz8I GpzgWcCkKEOxGvQwwXUsxy1ebcN7ZtyVDqTzsf5pJKtP5VuetW96n50Pipc5nL9BS8zp wjc4SQAq2KBrheN5H0ZBovOIG+nrNE6nn/hWmYC5GLJ6FDDhLumnrtMoWTOQ81S88xml vKWkJI8MoLrd5Z+H8caKhnG3JpgU/fJFXteKW7xMiRtUIacva9fX2Wy1GOn3VO8b1J+4 N1sqdnsIvouu3P/EMzBTQh82sP8zTpzNURD0zQA2vjqBTIAwPY4RAHnDLMKIVdgPjkzc SBBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TMi0rpjvwNLHZrVufPOOndRr3cEZbnUmp8cEObDhWWM=; b=fF+PhenH6c3zNpX0oyXY44zdcBhMUjUbPrwoig5eIdILd0r0rq+Xnc6tOMGUVwJdpv lFfQQ1ovQOFIusWs2NIqk1t7844aStdozr6Whn4ZpBmTahVq6PCfY/JNo460f6ZBy087 kjEkx3klCxkh0vjk8UYDi4ABaL0yKKGJKFZROBM8VgnmFLCPD8ZJld5pg311NlDKcnej xuaJfl3sTFg/X94pH0hZxaQK/j7oXAH2EkR1t9NHZXK3CHtqVynWKMcfyUpZvf2A1I4q kyWFDIrVDVZ1Ja/r2TEGv9mVa3mpVGcd2mFjKXD2WY45R9kmrYyxn+EyvNCH40R2eDyX fOJg== X-Gm-Message-State: ANoB5pkSnKLd59dEpP51oR6lUMKLrzZSP199feoCsXAaOdhGJgI9XOlJ AL2trLm9jMU+4WcYk7HgP0o= X-Received: by 2002:a17:902:ce90:b0:186:b46d:da5e with SMTP id f16-20020a170902ce9000b00186b46dda5emr69865167plg.92.1670314662580; Tue, 06 Dec 2022 00:17:42 -0800 (PST) Received: from localhost.localdomain ([202.120.234.246]) by smtp.googlemail.com with ESMTPSA id h15-20020a056a00000f00b00574d38f4d37sm11177289pfk.45.2022.12.06.00.17.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 00:17:41 -0800 (PST) From: Miaoqian Lin To: Andy Gross , Bjorn Andersson , Konrad Dybcio , Thinh Nguyen , Greg Kroah-Hartman , Sandeep Maheswaram , Matthias Kaehlcke , Chandana Kishori Chiluveru , Felipe Balbi , linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linmq006@gmail.com Subject: [PATCH] usb: dwc3: qcom: Fix memory leak in dwc3_qcom_interconnect_init Date: Tue, 6 Dec 2022 12:17:31 +0400 Message-Id: <20221206081731.818107-1-linmq006@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751452174821699690?= X-GMAIL-MSGID: =?utf-8?q?1751452174821699690?= of_icc_get() alloc resources for path handle, we should release it when not need anymore. Like the release in dwc3_qcom_interconnect_exit() function. Add icc_put() in error handling to fix this. Fixes: bea46b981515 ("usb: dwc3: qcom: Add interconnect support in dwc3 driver") Signed-off-by: Miaoqian Lin Acked-by: Thinh Nguyen --- drivers/usb/dwc3/dwc3-qcom.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c index 7c40f3ffc054..b0a0351d2d8b 100644 --- a/drivers/usb/dwc3/dwc3-qcom.c +++ b/drivers/usb/dwc3/dwc3-qcom.c @@ -261,7 +261,8 @@ static int dwc3_qcom_interconnect_init(struct dwc3_qcom *qcom) if (IS_ERR(qcom->icc_path_apps)) { dev_err(dev, "failed to get apps-usb path: %ld\n", PTR_ERR(qcom->icc_path_apps)); - return PTR_ERR(qcom->icc_path_apps); + ret = PTR_ERR(qcom->icc_path_apps); + goto put_path_ddr; } max_speed = usb_get_maximum_speed(&qcom->dwc3->dev); @@ -274,16 +275,22 @@ static int dwc3_qcom_interconnect_init(struct dwc3_qcom *qcom) } if (ret) { dev_err(dev, "failed to set bandwidth for usb-ddr path: %d\n", ret); - return ret; + goto put_path_apps; } ret = icc_set_bw(qcom->icc_path_apps, APPS_USB_AVG_BW, APPS_USB_PEAK_BW); if (ret) { dev_err(dev, "failed to set bandwidth for apps-usb path: %d\n", ret); - return ret; + goto put_path_apps; } return 0; + +put_path_apps: + icc_put(qcom->icc_path_apps); +put_path_ddr: + icc_put(qcom->icc_path_ddr); + return ret; } /**