Commit e2eae099 authored by Yu Kuai's avatar Yu Kuai Committed by Will Deacon
Browse files

iommu/qcom: add missing put_device() call in qcom_iommu_of_xlate()



if of_find_device_by_node() succeed, qcom_iommu_of_xlate() doesn't have
a corresponding put_device(). Thus add put_device() to fix the exception
handling for this function implementation.

Fixes: 0ae349a0 ("iommu/qcom: Add qcom_iommu")
Acked-by: default avatarRob Clark <robdclark@gmail.com>
Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Link: https://lore.kernel.org/r/20200929014037.2436663-1-yukuai3@huawei.com


Signed-off-by: default avatarWill Deacon <will@kernel.org>
parent f534d98b
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -584,8 +584,10 @@ static int qcom_iommu_of_xlate(struct device *dev, struct of_phandle_args *args)
	 * index into qcom_iommu->ctxs:
	 */
	if (WARN_ON(asid < 1) ||
	    WARN_ON(asid > qcom_iommu->num_ctxs))
	    WARN_ON(asid > qcom_iommu->num_ctxs)) {
		put_device(&iommu_pdev->dev);
		return -EINVAL;
	}

	if (!dev_iommu_priv_get(dev)) {
		dev_iommu_priv_set(dev, qcom_iommu);
@@ -594,9 +596,11 @@ static int qcom_iommu_of_xlate(struct device *dev, struct of_phandle_args *args)
		 * multiple different iommu devices.  Multiple context
		 * banks are ok, but multiple devices are not:
		 */
		if (WARN_ON(qcom_iommu != dev_iommu_priv_get(dev)))
		if (WARN_ON(qcom_iommu != dev_iommu_priv_get(dev))) {
			put_device(&iommu_pdev->dev);
			return -EINVAL;
		}
	}

	return iommu_fwspec_add_ids(dev, &asid, 1);
}