From nobody Fri Oct 17 13:24:07 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA1A2C4332F for ; Wed, 19 Oct 2022 09:16:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233197AbiJSJQf (ORCPT ); Wed, 19 Oct 2022 05:16:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233103AbiJSJN7 (ORCPT ); Wed, 19 Oct 2022 05:13:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09367CF185; Wed, 19 Oct 2022 02:03:51 -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 705F46181B; Wed, 19 Oct 2022 09:03:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82E2EC433D6; Wed, 19 Oct 2022 09:03:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170193; bh=cciPacl9eT/Q43v963/166drUbkyCCfGboVieuGeFvc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v/KIgXYxzYWLQfL4y91kDI/OroeY9ugZd02ZZLSLKlo+dWZdT+PuU4+meHX41Qk/W qSTVHTE8ZzSBd3AuHhGhv4f0P3DbEilwnYFhqC66C+DWhE/qmYHm1pT6fvB1sKOPDb bJOb0+0JA/gkI/xk89xIl2KFAtK2Y3sr4FZQnoNk= 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 526/862] phy: qcom-qmp-combo: fix memleak on probe deferral Date: Wed, 19 Oct 2022 10:30:13 +0200 Message-Id: <20221019083313.221255789@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-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Johan Hovold [ Upstream commit 2de8a325b1084330ae500380cc27edc39f488c30 ] 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-5-johan+linaro@kernel.= org Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 32 ++++++++++++----------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualco= mm/phy-qcom-qmp-combo.c index bbdca263058c..f089977c85bb 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c @@ -2350,17 +2350,17 @@ int qcom_qmp_phy_combo_create(struct device *dev, s= truct device_node *np, int id * For dual lane PHYs: tx2 -> 3, rx2 -> 4, pcs_misc (optional) -> 5 * For single lane PHYs: pcs_misc (optional) -> 3. */ - qphy->tx =3D of_iomap(np, 0); - if (!qphy->tx) - return -ENOMEM; + qphy->tx =3D devm_of_iomap(dev, np, 0, NULL); + if (IS_ERR(qphy->tx)) + return PTR_ERR(qphy->tx); =20 - qphy->rx =3D of_iomap(np, 1); - if (!qphy->rx) - return -ENOMEM; + qphy->rx =3D devm_of_iomap(dev, np, 1, NULL); + if (IS_ERR(qphy->rx)) + return PTR_ERR(qphy->rx); =20 - qphy->pcs =3D of_iomap(np, 2); - if (!qphy->pcs) - return -ENOMEM; + qphy->pcs =3D devm_of_iomap(dev, np, 2, NULL); + if (IS_ERR(qphy->pcs)) + return PTR_ERR(qphy->pcs); =20 if (cfg->pcs_usb_offset) qphy->pcs_usb =3D qphy->pcs + cfg->pcs_usb_offset; @@ -2372,9 +2372,9 @@ int qcom_qmp_phy_combo_create(struct device *dev, str= uct device_node *np, int id * offset from the first lane. */ if (cfg->is_dual_lane_phy) { - qphy->tx2 =3D of_iomap(np, 3); - qphy->rx2 =3D of_iomap(np, 4); - if (!qphy->tx2 || !qphy->rx2) { + qphy->tx2 =3D devm_of_iomap(dev, np, 3, NULL); + qphy->rx2 =3D devm_of_iomap(dev, np, 4, NULL); + if (IS_ERR(qphy->tx2) || IS_ERR(qphy->rx2)) { dev_warn(dev, "Underspecified device tree, falling back to legacy register regions\= n"); =20 @@ -2384,15 +2384,17 @@ int qcom_qmp_phy_combo_create(struct device *dev, s= truct device_node *np, int id qphy->rx2 =3D qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; =20 } else { - qphy->pcs_misc =3D of_iomap(np, 5); + qphy->pcs_misc =3D devm_of_iomap(dev, np, 5, NULL); } =20 } else { - qphy->pcs_misc =3D of_iomap(np, 3); + qphy->pcs_misc =3D devm_of_iomap(dev, np, 3, NULL); } =20 - if (!qphy->pcs_misc) + if (IS_ERR(qphy->pcs_misc)) { dev_vdbg(dev, "PHY pcs_misc-reg not used\n"); + qphy->pcs_misc =3D NULL; + } =20 /* * Get PHY's Pipe clock, if any. USB3 and PCIe are PIPE3 --=20 2.35.1