Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1109539rwi; Wed, 19 Oct 2022 06:53:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5sALprXP4vAvvTSNEOl4nHWmcIgFRg2NM+Kg+eIFag+xMjzNcOII11SZQFc3zmpu65NY/P X-Received: by 2002:a63:2155:0:b0:455:7b5b:c2d7 with SMTP id s21-20020a632155000000b004557b5bc2d7mr7217194pgm.309.1666187589706; Wed, 19 Oct 2022 06:53:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666187589; cv=none; d=google.com; s=arc-20160816; b=1B7Anv8DDb2incU9lNBgKHkmDHN3vH3mfB7kdyskI6rcrAy42jkJ62V9Wrl1wOfw8R FQgO7AA5ijdASY3CXWjFcvSyHa+LxykwY0DAtBrrsuWOXOBkfMkVnYLbJ/M+garUtQmk 9yl9zX+kgnwuWZjMZp0/gRONdwodrsne4xcSCZ/95Fdpj79RveNCE3pU+i39tmothBvV meYkvZt9UrnnS9X+Zgy2cVzyhm3xrvbug+7RyEL2AKbCkgmta/XOr5Ljiq6peOQkaZr1 fVJ2poo+KB6i/nit2cSzYdss1ZHAFKjH+HjY7CsD4Moiwc2yAJ+P6+ToNyG24/3Xrsoi n7sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=r3A2OgBseSvLNnXtGfzk581GkGrssn8nSwCBNSRoNTU=; b=OLU4bOJptqGy5HqVhj51jlePcExxDp9XNq6IjJ09z+BMTHdD47bGELk0ieq5D3sJXH a0Rkx2YdiQUBAnRcCu6kRftqrqIlmDudqnzHTWn97MSq0Qw3ciw5hK4cAYV3sX3Q3/og XZYhATKkXH4HhKidhOUzyU76syuen7NJrS8xxMsJJGjxrUobERTLJ4wjYRzW9yNRxGg/ 3SFkJQpDa5RM8XQV8PtVHI+da+uiSzopFS/+M6qK1q8UjX5tRcf44cx8G8AFwDvHkw6Q hWbyZA804vaSCaq2SOBWeJJHJZGEj5Q4hdY9jSbIuk08yVCv/3YpqdAC7bm+rTiG85pp /r8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AKpJsdE5; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q32-20020a17090a4fa300b002057a08d66asi28715pjh.23.2022.10.19.06.52.54; Wed, 19 Oct 2022 06:53:09 -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=@kernel.org header.s=k20201202 header.b=AKpJsdE5; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233103AbiJSNpo (ORCPT + 99 others); Wed, 19 Oct 2022 09:45:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233557AbiJSNoY (ORCPT ); Wed, 19 Oct 2022 09:44:24 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6C141D345D; Wed, 19 Oct 2022 06:31:42 -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 sin.source.kernel.org (Postfix) with ESMTPS id 0A70ACE2202; Wed, 19 Oct 2022 09:17:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3109FC433C1; Wed, 19 Oct 2022 09:17:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666171055; bh=IALyVF24HY9xflgysUmvPocIS1MzwmyKLjdMduM7X1Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AKpJsdE5cg5g0wiap61DLwNeC6lurl02KJcIKeTMVZY+rXLQHnLrCeayi9MNCZTHj Yy0XawoJkTzxEy6DaxKiRSabln3KGmetEqjcsJZ5d7g2C/FxasWExV51pODFWgTyKx 2wDIlQzy+RCAnTSJ/Cu9O21WwcHWmnaatjtGZ+5qowaq1X9tlP3zX0mAwRd5zF9ZLK 0lObLGyLtvnOBUuhyiT2vxfbsYPzbczPmr4PdB5pg9hagUYbsghKq12FOX7jU4AHjC /CHqv6lAprwNvDop/L0VNkoYQ01OqCPHr1O8QRKB15ba3narTc76gX+18cGcfcXnmY pRYYozY4VK3wg== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1ol5CV-00056k-AZ; Wed, 19 Oct 2022 11:17:23 +0200 Date: Wed, 19 Oct 2022 11:17:23 +0200 From: Johan Hovold To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Johan Hovold , Vinod Koul , Sasha Levin Subject: Re: [PATCH 6.0 524/862] phy: qcom-qmp-pcie: fix memleak on probe deferral Message-ID: References: <20221019083249.951566199@linuxfoundation.org> <20221019083313.126741569@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221019083313.126741569@linuxfoundation.org> 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 On Wed, Oct 19, 2022 at 10:30:11AM +0200, Greg Kroah-Hartman wrote: > From: Johan Hovold > > [ Upstream commit 4be26f695ffa458b065b7942dbff9393bf0836ea ] > > 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. In case of a malformed dts, the above new check can prevent the driver from binding. Fixing tiny memory leaks on driver unbind does not outweigh that risk and, again, the stable tag was left out on purpose. Please drop. > 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-3-johan+linaro@kernel.org > Signed-off-by: Vinod Koul > Signed-off-by: Sasha Levin > --- > drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 34 ++++++++++++------------ > 1 file changed, 17 insertions(+), 17 deletions(-) > > diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c > index 0e0f2482827a..819bcd975ba4 100644 > --- a/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c > +++ b/drivers/phy/qualcomm/phy-qcom-qmp-pcie.c > @@ -2329,17 +2329,17 @@ int qcom_qmp_phy_pcie_create(struct device *dev, struct 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 = of_iomap(np, 0); > - if (!qphy->tx) > - return -ENOMEM; > + qphy->tx = devm_of_iomap(dev, np, 0, NULL); > + if (IS_ERR(qphy->tx)) > + return PTR_ERR(qphy->tx); > > - qphy->rx = of_iomap(np, 1); > - if (!qphy->rx) > - return -ENOMEM; > + qphy->rx = devm_of_iomap(dev, np, 1, NULL); > + if (IS_ERR(qphy->rx)) > + return PTR_ERR(qphy->rx); > > - qphy->pcs = of_iomap(np, 2); > - if (!qphy->pcs) > - return -ENOMEM; > + qphy->pcs = devm_of_iomap(dev, np, 2, NULL); > + if (IS_ERR(qphy->pcs)) > + return PTR_ERR(qphy->pcs); > > /* > * If this is a dual-lane PHY, then there should be registers for the > @@ -2348,9 +2348,9 @@ int qcom_qmp_phy_pcie_create(struct device *dev, struct device_node *np, int id, > * offset from the first lane. > */ > if (cfg->is_dual_lane_phy) { > - qphy->tx2 = of_iomap(np, 3); > - qphy->rx2 = of_iomap(np, 4); > - if (!qphy->tx2 || !qphy->rx2) { > + qphy->tx2 = devm_of_iomap(dev, np, 3, NULL); > + qphy->rx2 = 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"); > > @@ -2360,20 +2360,20 @@ int qcom_qmp_phy_pcie_create(struct device *dev, struct device_node *np, int id, > qphy->rx2 = qphy->rx + QMP_PHY_LEGACY_LANE_STRIDE; > > } else { > - qphy->pcs_misc = of_iomap(np, 5); > + qphy->pcs_misc = devm_of_iomap(dev, np, 5, NULL); > } > > } else { > - qphy->pcs_misc = of_iomap(np, 3); > + qphy->pcs_misc = devm_of_iomap(dev, np, 3, NULL); > } > > - if (!qphy->pcs_misc && > + if (IS_ERR(qphy->pcs_misc) && > of_device_is_compatible(dev->of_node, "qcom,ipq6018-qmp-pcie-phy")) > qphy->pcs_misc = qphy->pcs + 0x400; > > - if (!qphy->pcs_misc) { > + if (IS_ERR(qphy->pcs_misc)) { > if (cfg->pcs_misc_tbl || cfg->pcs_misc_tbl_sec) > - return -EINVAL; > + return PTR_ERR(qphy->pcs_misc); > } > > snprintf(prop_name, sizeof(prop_name), "pipe%d", id); Johan