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 7386D35BDA8; Fri, 9 Jan 2026 12:51:59 +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=1767963119; cv=none; b=mXBfhQNrwoFdhttutI7Wdqzi7IAWxLjkkRWlQBeULJWrRsKU8b1KzYlLHk+E4RhQm75Y0xiZmpJhOUVUrguNdqPABitIZhqTJEP+5kS2m5eVrV+F9FTIXUMUKuA3d3HNhYCWqDYg95ngZ09qdsloO9WP7PF4fx2y0O53HPzH04U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767963119; c=relaxed/simple; bh=tMBOgZG4s+JI1Kl0RRxMr5arUUxZYkYjFeogHbpYqmE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o0RdXeOR+OFeXo2qrk9iHGgUdpFUgIPdw2nxn0c3ssT3xKWaC7O9PZnYlKc/sKxnoahfSHoTPi3LhGp2nG5QXPlsDI5lfjkql7qx0I6XOhdPfvTdwcAy7VlTQQNSenhQsH9tTz7jYRyVmn7xGsDcgVu0oMMU92vEzf+cPJCQyPQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kDQWevlS; 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="kDQWevlS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D31AC4CEF1; Fri, 9 Jan 2026 12:51:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1767963119; bh=tMBOgZG4s+JI1Kl0RRxMr5arUUxZYkYjFeogHbpYqmE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kDQWevlSK8qgd2gWMtCDbOosJARMrr8wT95/dARhZYT/KzcY1L5yWHNwnMG7ECYa6 jOS0AIqMi/KODMRI7U0/S/ixhDjpETQE5K8di5tiRde+XL0dtNluK9a38xdf44JCYr 4dSOk1eV4FvRPtgbfRavquSEOxWBhg9ngfU7W99Q= 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 , Sasha Levin Subject: [PATCH 6.1 604/634] iommu/qcom: fix device leak on of_xlate() Date: Fri, 9 Jan 2026 12:44:42 +0100 Message-ID: <20260109112140.356044677@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260109112117.407257400@linuxfoundation.org> References: <20260109112117.407257400@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Johan Hovold [ Upstream commit 6a3908ce56e6879920b44ef136252b2f0c954194 ] 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: Sasha Levin 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 @@ -558,14 +558,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); @@ -574,10 +574,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);