* [PATCH] iommu/amd: Drop incorrect NULL check for iommu in alloc_irq_table()
@ 2025-12-22 17:10 Rakuram Eswaran
2025-12-24 13:43 ` Ankit Soni
2026-01-10 10:18 ` Jörg Rödel
0 siblings, 2 replies; 3+ messages in thread
From: Rakuram Eswaran @ 2025-12-22 17:10 UTC (permalink / raw)
To: joro, will, suravee.suthikulpanit, robin.murphy, iommu
Cc: dan.carpenter, lkp, linux-kernel, rakuram.e96
alloc_irq_table() contains a conditional check for a NULL iommu pointer
when computing the NUMA node, but the function dereferences iommu
in multiple places afterwards.
All callers ensure that a valid iommu pointer is passed in, and a NULL
iommu is not expected by the current callers. Remove the incorrect
NULL check to make the assumptions consistent and address the Smatch
warning.
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/r/202512191724.meqJENXe-lkp@intel.com/
Signed-off-by: Rakuram Eswaran <rakuram.e96@gmail.com>
---
Testing note:
Compile tested only.
Build and Analysis:
This patch was compiled against the configuration file reported by
0day CI in the above link (config: x86_64-randconfig-r073-20251215)
using gcc version 15.2.0 (Ubuntu 15.2.0-4ubuntu4).
Static analysis was performed with Smatch to ensure the reported warning
no longer reproduces after applying this fix.
Command using for Smatch testing:
~/project/smatch/smatch_scripts/kchecker ./drivers/iommu/amd/iommu.c
drivers/iommu/amd/iommu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index 075125f0f52b..611e3ccc93d1 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -3240,7 +3240,7 @@ static struct irq_remap_table *alloc_irq_table(struct amd_iommu *iommu,
struct irq_remap_table *new_table = NULL;
struct amd_iommu_pci_seg *pci_seg;
unsigned long flags;
- int nid = iommu && iommu->dev ? dev_to_node(&iommu->dev->dev) : NUMA_NO_NODE;
+ int nid = iommu->dev ? dev_to_node(&iommu->dev->dev) : NUMA_NO_NODE;
u16 alias;
spin_lock_irqsave(&iommu_table_lock, flags);
--
2.51.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iommu/amd: Drop incorrect NULL check for iommu in alloc_irq_table()
2025-12-22 17:10 [PATCH] iommu/amd: Drop incorrect NULL check for iommu in alloc_irq_table() Rakuram Eswaran
@ 2025-12-24 13:43 ` Ankit Soni
2026-01-10 10:18 ` Jörg Rödel
1 sibling, 0 replies; 3+ messages in thread
From: Ankit Soni @ 2025-12-24 13:43 UTC (permalink / raw)
To: Rakuram Eswaran
Cc: joro, will, suravee.suthikulpanit, robin.murphy, iommu,
dan.carpenter, lkp, linux-kernel
On Mon, Dec 22, 2025 at 10:40:08PM +0530, Rakuram Eswaran wrote:
> alloc_irq_table() contains a conditional check for a NULL iommu pointer
> when computing the NUMA node, but the function dereferences iommu
> in multiple places afterwards.
>
> All callers ensure that a valid iommu pointer is passed in, and a NULL
> iommu is not expected by the current callers. Remove the incorrect
> NULL check to make the assumptions consistent and address the Smatch
> warning.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/r/202512191724.meqJENXe-lkp@intel.com/
> Signed-off-by: Rakuram Eswaran <rakuram.e96@gmail.com>
Looks good to me.
Reviewed-by: Ankit Soni <Ankit.Soni@amd.com>
> ---
> Testing note:
> Compile tested only.
>
> Build and Analysis:
> This patch was compiled against the configuration file reported by
> 0day CI in the above link (config: x86_64-randconfig-r073-20251215)
> using gcc version 15.2.0 (Ubuntu 15.2.0-4ubuntu4).
>
> Static analysis was performed with Smatch to ensure the reported warning
> no longer reproduces after applying this fix.
>
> Command using for Smatch testing:
> ~/project/smatch/smatch_scripts/kchecker ./drivers/iommu/amd/iommu.c
>
> drivers/iommu/amd/iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index 075125f0f52b..611e3ccc93d1 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -3240,7 +3240,7 @@ static struct irq_remap_table *alloc_irq_table(struct amd_iommu *iommu,
> struct irq_remap_table *new_table = NULL;
> struct amd_iommu_pci_seg *pci_seg;
> unsigned long flags;
> - int nid = iommu && iommu->dev ? dev_to_node(&iommu->dev->dev) : NUMA_NO_NODE;
> + int nid = iommu->dev ? dev_to_node(&iommu->dev->dev) : NUMA_NO_NODE;
> u16 alias;
>
> spin_lock_irqsave(&iommu_table_lock, flags);
> --
> 2.51.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iommu/amd: Drop incorrect NULL check for iommu in alloc_irq_table()
2025-12-22 17:10 [PATCH] iommu/amd: Drop incorrect NULL check for iommu in alloc_irq_table() Rakuram Eswaran
2025-12-24 13:43 ` Ankit Soni
@ 2026-01-10 10:18 ` Jörg Rödel
1 sibling, 0 replies; 3+ messages in thread
From: Jörg Rödel @ 2026-01-10 10:18 UTC (permalink / raw)
To: Rakuram Eswaran
Cc: will, suravee.suthikulpanit, robin.murphy, iommu, dan.carpenter,
lkp, linux-kernel
On Mon, Dec 22, 2025 at 10:40:08PM +0530, Rakuram Eswaran wrote:
> drivers/iommu/amd/iommu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-10 10:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-22 17:10 [PATCH] iommu/amd: Drop incorrect NULL check for iommu in alloc_irq_table() Rakuram Eswaran
2025-12-24 13:43 ` Ankit Soni
2026-01-10 10:18 ` Jörg Rödel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®