From mboxrd@z Thu Jan 1 00:00:00 1970 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 500121F1932; Tue, 6 Jan 2026 17:34:16 +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=1767720856; cv=none; b=OqqOMeyNZcfcS62+Ko/TaI/pF3wihLFZhnsEjycHBsBhbBOo6tFCMWq6AMllRy4+ova8JhWvaU1/FQzyi5LzX0HjFXHZ6NN5nutzIkXEQGT2/cTZO4J9Be9llNgJC+IMuyVoBORGyKvta1ruWj9ifdkf6SySqEW80YjIt/L4Qy0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767720856; c=relaxed/simple; bh=7jTXY/5Q7rIGDs7n9tAlbqeTjMloojezi1z8j2AG3DM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BeBJ/HMEzgSoITsMoZGMg8tDbx4p7NlhOZ+CwrLS2IHr43HG7v5RQlD0tSEKk+oD1lE5WacajxBvG3obgMvfvDhQnA4l4ez4LxlpsLmj8lAJkZ6uO0kKhlWfwIY+YNOT41heew5mujALEB0SvydapE/hCzaFiLEyIHJTmPv1aOo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=r1RaLhhT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="r1RaLhhT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B33E7C116C6; Tue, 6 Jan 2026 17:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1767720856; bh=7jTXY/5Q7rIGDs7n9tAlbqeTjMloojezi1z8j2AG3DM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r1RaLhhTvyA/3j84Xi+f426SI7RFo7ZvsogmrbKxUDPiWy9zhH7IA0TDcVPmA9E0r wSv59iTeag9qIkoyRD26eUM42Od/hbhLpl8xOn4PkjjdoMf95POaE98ePXmOJOEDlc +RSHYtAs06TwiAF1URbl0kiG0Xw003cnOmGkBdDY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Rob Clark , Yu Kuai , Robin Murphy , Johan Hovold , Joerg Roedel Subject: [PATCH 6.12 363/567] iommu/qcom: fix device leak on of_xlate() Date: Tue, 6 Jan 2026 18:02:25 +0100 Message-ID: <20260106170504.766416100@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260106170451.332875001@linuxfoundation.org> References: <20260106170451.332875001@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johan Hovold commit 6a3908ce56e6879920b44ef136252b2f0c954194 upstream. 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 Acked-by: Robin Murphy Signed-off-by: Johan Hovold Signed-off-by: Joerg Roedel Signed-off-by: Greg Kroah-Hartman --- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) --- a/drivers/iommu/arm/arm-smmu/qcom_iommu.c +++ b/drivers/iommu/arm/arm-smmu/qcom_iommu.c @@ -566,14 +566,14 @@ static int qcom_iommu_of_xlate(struct de qcom_iommu = platform_get_drvdata(iommu_pdev); + 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] == NULL)) { - put_device(&iommu_pdev->dev); + WARN_ON(qcom_iommu->ctxs[asid] == NULL)) return -EINVAL; - } if (!dev_iommu_priv_get(dev)) { dev_iommu_priv_set(dev, qcom_iommu); @@ -582,10 +582,8 @@ static int qcom_iommu_of_xlate(struct de * multiple different iommu devices. Multiple context * banks are ok, but multiple devices are not: */ - if (WARN_ON(qcom_iommu != dev_iommu_priv_get(dev))) { - put_device(&iommu_pdev->dev); + if (WARN_ON(qcom_iommu != dev_iommu_priv_get(dev))) return -EINVAL; - } } return iommu_fwspec_add_ids(dev, &asid, 1);