Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp810680rwi; Wed, 19 Oct 2022 03:18:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5tI/6Qq8BuAwbAoJSFpTfET7l6JraszWuY76mbAnqDLHq8Z0zCvdNXrNxY4a62BqvlpC8D X-Received: by 2002:a17:907:2c74:b0:78d:b3ae:8408 with SMTP id ib20-20020a1709072c7400b0078db3ae8408mr6162101ejc.172.1666174731931; Wed, 19 Oct 2022 03:18:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666174731; cv=none; d=google.com; s=arc-20160816; b=L7p2HHhKoxaYcsUhoUMAiLGHFy80bZvmFihDyEgdtmrgGNzHdwDiwV9eutLA6WjoRC v8EM/i5PxaBNF1FWpiaMDFXGEDEg3obnbHScTnUxWah5hMc3akq+xYJBkaOqvJhZ35sz SLQnFe6MUHhG7l5evwMcOgUS+LLtJBHHBZCISsYXK/5HOrZ1ZGf3VN1OijSztPrhikUr /zKsSOSQyWQfmOFcGSJfuMTKq7j/4Y3sBZqq0DCDJkUkqSdI0jm5t7Ko2EHj6akdh+5F f2eeMGQxpjJHSBpmgzUWjtj7X0WJ4PLFooiOIxGX9Gy29l2uazMrtIFhTL94JEtbpUGq hgxg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ho36-20020a1709070ea400b007919f213511si3427421ejc.951.2022.10.19.03.18.25; Wed, 19 Oct 2022 03:18:51 -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 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: 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); -- 2.35.1