All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] iommu/amd: two tiny cleanups
@ 2025-03-17  6:42 Dan Carpenter
  2025-03-17  6:43 ` [PATCH 1/2] iommu/amd: Delete unnecessary NULL check Dan Carpenter
  2025-03-17  6:43 ` [PATCH 2/2] iommu/amd: Return a literal in init_gcr3_table() Dan Carpenter
  0 siblings, 2 replies; 5+ messages in thread
From: Dan Carpenter @ 2025-03-17  6:42 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: iommu, linux-kernel, Robin Murphy, Suravee Suthikulpanit,
	Will Deacon

Delete an unnecessary NULL check and return a literal zero instead
of "ret" (where ret is zero).

Dan Carpenter (2):
  iommu/amd: Delete unnecessary NULL check
  iommu/amd: Return a literal in init_gcr3_table()

 drivers/iommu/amd/iommu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.47.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] iommu/amd: Delete unnecessary NULL check
  2025-03-17  6:42 [PATCH 0/2] iommu/amd: two tiny cleanups Dan Carpenter
@ 2025-03-17  6:43 ` Dan Carpenter
  2025-03-17  6:43 ` [PATCH 2/2] iommu/amd: Return a literal in init_gcr3_table() Dan Carpenter
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2025-03-17  6:43 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: Suravee Suthikulpanit, Will Deacon, Robin Murphy, iommu,
	linux-kernel

The "iommu" pointer is always valid at this point so there is no
need to check for NULL.  Checking for NULL triggers a Smatch warning
because it's dereferenced without a check a couple lines later:

    drivers/iommu/amd/iommu.c:3200 alloc_irq_table()
    error: we previously assumed 'iommu' could be null (see line 3195)

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 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 be8761bbef0f..ce2626801ddf 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -3192,7 +3192,7 @@ static struct irq_remap_table *alloc_irq_table(struct amd_iommu *iommu,
 	struct amd_iommu_pci_seg *pci_seg;
 	unsigned long flags;
 	int order = get_order(get_irq_table_size(max_irqs));
-	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.47.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] iommu/amd: Return a literal in init_gcr3_table()
  2025-03-17  6:42 [PATCH 0/2] iommu/amd: two tiny cleanups Dan Carpenter
  2025-03-17  6:43 ` [PATCH 1/2] iommu/amd: Delete unnecessary NULL check Dan Carpenter
@ 2025-03-17  6:43 ` Dan Carpenter
  2025-03-20  8:03   ` Joerg Roedel
  1 sibling, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2025-03-17  6:43 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: Suravee Suthikulpanit, Will Deacon, Robin Murphy, iommu,
	linux-kernel

This code intentionally returns zero but it does it as "return ret;"
Returning ret looks like an error path where return 0 is more
clear and looks more intentional.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 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 ce2626801ddf..7cbcc4933c8b 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -2150,7 +2150,7 @@ static int init_gcr3_table(struct iommu_dev_data *dev_data,
 
 	/* Setup GCR3[0] only if domain is setup with v2 page table mode */
 	if (!pdom_is_v2_pgtbl_mode(pdom))
-		return ret;
+		return 0;
 
 	ret = update_gcr3(dev_data, 0, iommu_virt_to_phys(pdom->iop.pgd), true);
 	if (ret)
-- 
2.47.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] iommu/amd: Return a literal in init_gcr3_table()
  2025-03-17  6:43 ` [PATCH 2/2] iommu/amd: Return a literal in init_gcr3_table() Dan Carpenter
@ 2025-03-20  8:03   ` Joerg Roedel
  2025-03-20  8:53     ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Joerg Roedel @ 2025-03-20  8:03 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Suravee Suthikulpanit, Will Deacon, Robin Murphy, iommu,
	linux-kernel

On Mon, Mar 17, 2025 at 09:43:32AM +0300, Dan Carpenter wrote:
> This code intentionally returns zero but it does it as "return ret;"
> Returning ret looks like an error path where return 0 is more
> clear and looks more intentional.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  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 ce2626801ddf..7cbcc4933c8b 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -2150,7 +2150,7 @@ static int init_gcr3_table(struct iommu_dev_data *dev_data,
>  
>  	/* Setup GCR3[0] only if domain is setup with v2 page table mode */
>  	if (!pdom_is_v2_pgtbl_mode(pdom))
> -		return ret;
> +		return 0;

There is another case of this a couple lines above in the same function.
Mind changing that as well?

Regards,

	Joerg

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] iommu/amd: Return a literal in init_gcr3_table()
  2025-03-20  8:03   ` Joerg Roedel
@ 2025-03-20  8:53     ` Dan Carpenter
  0 siblings, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2025-03-20  8:53 UTC (permalink / raw)
  To: Joerg Roedel
  Cc: Suravee Suthikulpanit, Will Deacon, Robin Murphy, iommu,
	linux-kernel

On Thu, Mar 20, 2025 at 09:03:05AM +0100, Joerg Roedel wrote:
> On Mon, Mar 17, 2025 at 09:43:32AM +0300, Dan Carpenter wrote:
> > This code intentionally returns zero but it does it as "return ret;"
> > Returning ret looks like an error path where return 0 is more
> > clear and looks more intentional.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> >  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 ce2626801ddf..7cbcc4933c8b 100644
> > --- a/drivers/iommu/amd/iommu.c
> > +++ b/drivers/iommu/amd/iommu.c
> > @@ -2150,7 +2150,7 @@ static int init_gcr3_table(struct iommu_dev_data *dev_data,
> >  
> >  	/* Setup GCR3[0] only if domain is setup with v2 page table mode */
> >  	if (!pdom_is_v2_pgtbl_mode(pdom))
> > -		return ret;
> > +		return 0;
> 
> There is another case of this a couple lines above in the same function.
> Mind changing that as well?

Thanks.  Happy to.  I'll resend.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-03-20  8:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-17  6:42 [PATCH 0/2] iommu/amd: two tiny cleanups Dan Carpenter
2025-03-17  6:43 ` [PATCH 1/2] iommu/amd: Delete unnecessary NULL check Dan Carpenter
2025-03-17  6:43 ` [PATCH 2/2] iommu/amd: Return a literal in init_gcr3_table() Dan Carpenter
2025-03-20  8:03   ` Joerg Roedel
2025-03-20  8:53     ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.