From patchwork Wed Oct 19 08:30:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4790 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp216091wrs; Wed, 19 Oct 2022 02:17:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5NNLs3pbMIrlTHlQgyJZO7Lw3VTMyVm33bVfLz3ISDqGhph6eXTnb51BupXiyZux7BQXd3 X-Received: by 2002:a17:907:7e9e:b0:78d:f3b0:fc78 with SMTP id qb30-20020a1709077e9e00b0078df3b0fc78mr5937881ejc.478.1666171049955; Wed, 19 Oct 2022 02:17:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666171049; cv=none; d=google.com; s=arc-20160816; b=LvX1OZEy3PlQsfa+SGihhDSQ/o2XFS2ttBSMWAj2yPutFy8hs3seWck1Pu4V1Y8ct+ elxiBA1JTa6kr6zRH5xrVMEnO8JR/Q4xUaZBafWtN59nJ6oX/G2prajH5Mb0IXdwlvGV Bh/3CC2Lm+CMX+szlrk3uPOcUxu9F1kq8tD83K9AiuAnNvLshzEPJ67wDDCY2Rqbh701 JMKqJyb5EDu+fX5Hhymd+eMMjsZ8q/Y52ykZihxoBbeV8y/Ybd7QXjqN9Z1P0o5zvmc+ CKZwXnRFZ7d6PDLQ2lS6QnicMV2TeTWlRBvFWzNnkMRy24o73qdvV3tdL3Zs/YmG8Edk 8U5Q== 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=7qAuQX/qSMOqVUhXDB0vuZkaTJ86NAuOpDexf/Vn4Ao=; b=cbhRjC4kN5LzRIbYXIalR231JecVLY5zyMF5OQOxmo5+guepAWuHuBitGBNChBII// iEvOg+JaFJvsdJhi6RF5OpeBAR5Iy2dpVRJ9cKzyV0TvXirsY/cPQ/g10UqaVIBKmtM/ 7a2jpbYCEnRqJwDMxxly6FdXYcp1lzae+nfmeLYEH61k9AXiFObGr6TmBzbjnN+xC3Da v73iDqq4P5/myQ3Z4cABmm1FkqeQrplN+Reqz0REWdOzlVTEij2+6ZBeXIAtABwdgwTZ 7/bRc5s+LsL4h28UqdWlfvdVhYFUTrkGvrYGno9VnLkcoXsXpTi4+WKarcPGtfxQz7+5 NYog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="moHj1Nj/"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ti5-20020a170907c20500b007307fa2da78si10503192ejc.450.2022.10.19.02.17.03; Wed, 19 Oct 2022 02:17:29 -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="moHj1Nj/"; 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 S233181AbiJSJQZ (ORCPT + 99 others); Wed, 19 Oct 2022 05:16:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233088AbiJSJN5 (ORCPT ); Wed, 19 Oct 2022 05:13:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D0D598CA0; Wed, 19 Oct 2022 02:03:48 -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 dfw.source.kernel.org (Postfix) with ESMTPS id A6402617E8; Wed, 19 Oct 2022 09:03:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F852C433C1; Wed, 19 Oct 2022 09:03:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170191; bh=frTwBlKI1wjhe+k/zVR0m4zNwhuMu0VCaVx17vlF2lg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=moHj1Nj//T/UWdMquIEvG1Cyfm0I7+ed9HnbmE+3r7/2mctXGfn/cpK4HJZ9/GkSi mm+vuD6DfWxmAS4Dh7BEEZ/goA9k3C1bAE4vP/5OAsrm2wi7teYjfgKuOc+9dA5Iwm nsxA06kib5s2mPWpWtKfyZwKth/hoxYDqnxKBPeI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johan Hovold , Vinod Koul , Sasha Levin Subject: [PATCH 6.0 525/862] phy: qcom-qmp-pcie-msm8996: fix memleak on probe deferral Date: Wed, 19 Oct 2022 10:30:12 +0200 Message-Id: <20221019083313.175878033@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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747106974540444422?= X-GMAIL-MSGID: =?utf-8?q?1747106974540444422?= From: Johan Hovold [ Upstream commit 1f69ededf8e80c42352e7f1c165a003614de9cc2 ] Switch to using the device-managed of_iomap helper to avoid leaking memory on probe deferral and driver unbind. Note that this helper checks for already reserved regions and may fail if there are multiple devices claiming the same memory. Fixes: e78f3d15e115 ("phy: qcom-qmp: new qmp phy driver for qcom-chipsets") Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20220916102340.11520-4-johan+linaro@kernel.org Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- .../phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c b/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c index be6a94439b6c..14ea4ae95861 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-pcie-msm8996.c @@ -875,21 +875,20 @@ int qcom_qmp_phy_pcie_msm8996_create(struct device *dev, struct device_node *np, * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 * For single lane PHYs: pcs_misc (optional) -> 3. */ - qphy->tx = of_iomap(np, 0); - if (!qphy->tx) - return -ENOMEM; - - qphy->rx = of_iomap(np, 1); - if (!qphy->rx) - return -ENOMEM; + qphy->tx = devm_of_iomap(dev, np, 0, NULL); + if (IS_ERR(qphy->tx)) + return PTR_ERR(qphy->tx); - qphy->pcs = of_iomap(np, 2); - if (!qphy->pcs) - return -ENOMEM; + qphy->rx = devm_of_iomap(dev, np, 1, NULL); + if (IS_ERR(qphy->rx)) + return PTR_ERR(qphy->rx); - qphy->pcs_misc = of_iomap(np, 3); + qphy->pcs = devm_of_iomap(dev, np, 2, NULL); + if (IS_ERR(qphy->pcs)) + return PTR_ERR(qphy->pcs); - if (!qphy->pcs_misc) + qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL); + if (IS_ERR(qphy->pcs_misc)) dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); snprintf(prop_name, sizeof(prop_name), "pipe%d", id);