From nobody Thu Oct 2 02:04:53 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4508B2FE574; Thu, 25 Sep 2025 12:29:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758803350; cv=none; b=JYFzixrZNSIZmkhMZ/IcwAKC3sXPggqv5HixYhwC9Ajq/za8pMofx1I/50QR0x8WsrR5mB4/05Sp03jcQ3KOIQH6f6SYfM2XmajmSd2+EGD6ZHcBsTLxbcVcrezY57/WLN2XtxNPrkTUI2V5kShmBgpyaAgHEMapt6kZ3M15qzk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758803350; c=relaxed/simple; bh=fjAZkdmrtvGiYTWNqVeTxIY0d9WM6G8evCMPW+CVzGw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lRWntzoP1FEZ0qOVIVPy0M6e8HFo2MvpJXbneecdVPw7bbBoypEDcLeTwjtZ3YSCuzNuHkzaAifbwdAX39mGJpvbMBPYhLhUxhkg3hTLaeTN7bIzIxM84szun6qrsjHvRewZtzIyjGXBiqjf3rK3F+Ghz0wZswEvyK1I862YA8A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sVSNavgk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sVSNavgk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8960C4CEF7; Thu, 25 Sep 2025 12:29:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758803350; bh=fjAZkdmrtvGiYTWNqVeTxIY0d9WM6G8evCMPW+CVzGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sVSNavgkL7MHXwW+FVVq0YX2ksgJXZumplYeTyPCFhpc0O/ZOXbMiDpi59jATYvMH YFdwnjZrpF9wQZMlzmv7AudfVYvi5fbwd8id098jsrIKT/B0bEFIMlsT0x4L+5sUcm XpQ8DKk3hJ5OJbRDoRkwkUvXdERaPlQxX7kOEOVjiZigIdp627y1aQmBTM88Z0sWV7 m/hGHvhwHUESPeGaRiek6ZdTAKcbbzS5RLWIqInnUcpX5zg70GKaIlCb4iXsbadW1L P57LdAl346tAes0SjbpaCTOdNy62uvb0vCv3eIjOgQmV6l+MhfYU1oH0bfusRE46gb LKwBYRzTDJTnQ== Received: from johan by xi.lan with local (Exim 4.98.2) (envelope-from ) id 1v1l5q-000000002rU-1VHL; Thu, 25 Sep 2025 14:29:02 +0200 From: Johan Hovold To: Joerg Roedel , Will Deacon Cc: Robin Murphy , Sven Peter , Janne Grunau , Rob Clark , Marek Szyprowski , Yong Wu , Matthias Brugger , AngeloGioacchino Del Regno , Chen-Yu Tsai , Thierry Reding , Krishna Reddy , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Yu Kuai Subject: [PATCH 02/14] iommu/qcom: fix device leak on of_xlate() Date: Thu, 25 Sep 2025 14:27:44 +0200 Message-ID: <20250925122756.10910-3-johan@kernel.org> X-Mailer: git-send-email 2.49.1 In-Reply-To: <20250925122756.10910-1-johan@kernel.org> References: <20250925122756.10910-1-johan@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Make sure to drop the reference taken to the iommu platform device when looking up its driver data during of_xlate(). Note that commit e2eae09939a8 ("iommu/qcom: add missing put_device() call in qcom_iommu_of_xlate()") fixed the leak in a couple of error paths, but the reference is still leaking on success and late failures. Fixes: 0ae349a0f33f ("iommu/qcom: Add qcom_iommu") Cc: stable@vger.kernel.org # 4.14: e2eae09939a8 Cc: Rob Clark Cc: Yu Kuai Signed-off-by: Johan Hovold --- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu/qcom_iommu.c b/drivers/iommu/arm/ar= m-smmu/qcom_iommu.c index c5be95e56031..9c1166a3af6c 100644 --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c @@ -565,14 +565,14 @@ static int qcom_iommu_of_xlate(struct device *dev, =20 qcom_iommu =3D platform_get_drvdata(iommu_pdev); =20 + put_device(&iommu_pdev->dev); + /* make sure the asid specified in dt is valid, so we don't have * to sanity check this elsewhere: */ if (WARN_ON(asid > qcom_iommu->max_asid) || - WARN_ON(qcom_iommu->ctxs[asid] =3D=3D NULL)) { - put_device(&iommu_pdev->dev); + WARN_ON(qcom_iommu->ctxs[asid] =3D=3D NULL)) return -EINVAL; - } =20 if (!dev_iommu_priv_get(dev)) { dev_iommu_priv_set(dev, qcom_iommu); @@ -581,10 +581,8 @@ static int qcom_iommu_of_xlate(struct device *dev, * multiple different iommu devices. Multiple context * banks are ok, but multiple devices are not: */ - if (WARN_ON(qcom_iommu !=3D dev_iommu_priv_get(dev))) { - put_device(&iommu_pdev->dev); + if (WARN_ON(qcom_iommu !=3D dev_iommu_priv_get(dev))) return -EINVAL; - } } =20 return iommu_fwspec_add_ids(dev, &asid, 1); --=20 2.49.1