From f35f4e629ebc1950f46f9099e06e73602836f958 Mon Sep 17 00:00:00 2001 From: Zheng Zengkai Date: Mon, 12 Dec 2022 16:24:25 +0800 Subject: [PATCH] iommu: Fix error handling in probe_acpi_namespace_devices() hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I65QZY -------------------------------- Fix smatch error in probe_acpi_namespace_devices(). In probe_acpi_namespace_devices(), if device_to_iommu() returns NULL, unlock operation is needed before return. Fixes: d660222861c4 ("iommu/vt-d:Add support for detecting ACPI device, in RMRR") Signed-off-by: Zheng Zengkai Reviewed-by: Xiongfeng Wang Reviewed-by: Hanjun Guo --- drivers/iommu/intel/iommu.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 9e14cf9d875f..a1e56413600a 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4995,8 +4995,10 @@ static int __init probe_acpi_namespace_devices(void) } iommu = device_to_iommu(dev, &bus, &devfn); - if (!iommu) - return -ENODEV; + if (!iommu) { + ret = -ENODEV; + goto unlock; + } info = dmar_search_domain_by_dev_info(iommu->segment, bus, devfn); if (!info) { pn->dev->bus->iommu_ops = &intel_iommu_ops; @@ -5011,8 +5013,10 @@ static int __init probe_acpi_namespace_devices(void) } if (!pn_dev) { iommu = device_to_iommu(dev, &bus, &devfn); - if (!iommu) - return -ENODEV; + if (!iommu) { + ret = -ENODEV; + goto unlock; + } info = dmar_search_domain_by_dev_info(iommu->segment, bus, devfn); if (!info) { dev->bus->iommu_ops = &intel_iommu_ops; -- GitLab