All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cxl/pci: Fix potential bogus return value upon successful probing
@ 2024-11-14 21:34 Davidlohr Bueso
  2024-11-14 23:34 ` Fan Ni
  2024-11-15  2:56 ` Alison Schofield
  0 siblings, 2 replies; 5+ messages in thread
From: Davidlohr Bueso @ 2024-11-14 21:34 UTC (permalink / raw)
  To: dave.jiang
  Cc: dan.j.williams, alison.schofield, vishal.l.verma, ira.weiny,
	linux-cxl, dave

If cxl_pci_ras_unmask() returns non-zero, cxl_pci_probe() will end up
returning that value, instead of zero. Found by code inspeaction.

Fixes: 248529edc86 (cxl: add RAS status unmasking for CXL)
Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
---
 drivers/cxl/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
index 188412d45e0d..01092e5b3b46 100644
--- a/drivers/cxl/pci.c
+++ b/drivers/cxl/pci.c
@@ -948,7 +948,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	pci_save_state(pdev);
 
-	return rc;
+	return 0;
 }
 
 static const struct pci_device_id cxl_mem_pci_tbl[] = {
-- 
2.47.0


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

* Re: [PATCH] cxl/pci: Fix potential bogus return value upon successful probing
  2024-11-14 21:34 [PATCH] cxl/pci: Fix potential bogus return value upon successful probing Davidlohr Bueso
@ 2024-11-14 23:34 ` Fan Ni
  2024-11-15  2:56 ` Alison Schofield
  1 sibling, 0 replies; 5+ messages in thread
From: Fan Ni @ 2024-11-14 23:34 UTC (permalink / raw)
  To: Davidlohr Bueso
  Cc: dave.jiang, dan.j.williams, alison.schofield, vishal.l.verma,
	ira.weiny, linux-cxl

On Thu, Nov 14, 2024 at 01:34:39PM -0800, Davidlohr Bueso wrote:
> If cxl_pci_ras_unmask() returns non-zero, cxl_pci_probe() will end up
> returning that value, instead of zero. Found by code inspeaction.
/inspeaction/inspection/

Other than that,

Reviewed-by: Fan Ni <fan.ni@samsung.com>

Fan
> 
> Fixes: 248529edc86 (cxl: add RAS status unmasking for CXL)
> Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
> ---
>  drivers/cxl/pci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
> index 188412d45e0d..01092e5b3b46 100644
> --- a/drivers/cxl/pci.c
> +++ b/drivers/cxl/pci.c
> @@ -948,7 +948,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>  
>  	pci_save_state(pdev);
>  
> -	return rc;
> +	return 0;
>  }
>  
>  static const struct pci_device_id cxl_mem_pci_tbl[] = {

-- 
Fan Ni

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

* Re: [PATCH] cxl/pci: Fix potential bogus return value upon successful probing
  2024-11-14 21:34 [PATCH] cxl/pci: Fix potential bogus return value upon successful probing Davidlohr Bueso
  2024-11-14 23:34 ` Fan Ni
@ 2024-11-15  2:56 ` Alison Schofield
  2024-11-15 16:49   ` Davidlohr Bueso
  1 sibling, 1 reply; 5+ messages in thread
From: Alison Schofield @ 2024-11-15  2:56 UTC (permalink / raw)
  To: Davidlohr Bueso
  Cc: dave.jiang, dan.j.williams, vishal.l.verma, ira.weiny, linux-cxl

On Thu, Nov 14, 2024 at 01:34:39PM -0800, Davidlohr Bueso wrote:
> If cxl_pci_ras_unmask() returns non-zero, cxl_pci_probe() will end up
> returning that value, instead of zero. Found by code inspeaction.
>

I agree that the return value should be 0 if we get this far,
because all rc's that need to be returned, are returned immediately.

But...the set and check of 'rc' for the calls cannot lead to a
'return rc' seems like a bad pattern. Most of those are dev_dbg()
messages.

This last one that bit us here, is repeating the same pattern of those
before it:

	rc = cxl_pci_ras_unmask(pdev);
        if (rc)
                dev_dbg(&pdev->dev, "No RAS reporting unmasked\n");

This can be:

	if (cxl_pci_ras_unmask(pdev))
		dev_dbg(&pdev->dev, "No RAS reporting unmasked\n");

There are a bunch that follow this pattern in that function, mostly in
the pmu_count loop.

How about tidying up the rc pattern throughout the function?

--Alison


> Fixes: 248529edc86 (cxl: add RAS status unmasking for CXL)
> Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
> ---
>  drivers/cxl/pci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cxl/pci.c b/drivers/cxl/pci.c
> index 188412d45e0d..01092e5b3b46 100644
> --- a/drivers/cxl/pci.c
> +++ b/drivers/cxl/pci.c
> @@ -948,7 +948,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>  
>  	pci_save_state(pdev);
>  
> -	return rc;
> +	return 0;
>  }







>  
>  static const struct pci_device_id cxl_mem_pci_tbl[] = {
> -- 
> 2.47.0
> 
> 

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

* Re: [PATCH] cxl/pci: Fix potential bogus return value upon successful probing
  2024-11-15  2:56 ` Alison Schofield
@ 2024-11-15 16:49   ` Davidlohr Bueso
  2024-11-15 19:32     ` Ira Weiny
  0 siblings, 1 reply; 5+ messages in thread
From: Davidlohr Bueso @ 2024-11-15 16:49 UTC (permalink / raw)
  To: Alison Schofield
  Cc: dave.jiang, dan.j.williams, vishal.l.verma, ira.weiny, linux-cxl

On Thu, 14 Nov 2024, Alison Schofield wrote:\n
>This can be:
>
>	if (cxl_pci_ras_unmask(pdev))
>		dev_dbg(&pdev->dev, "No RAS reporting unmasked\n");

Yeah, it later occured to me that this was better. Will send a v2.

>
>There are a bunch that follow this pattern in that function, mostly in
>the pmu_count loop.
>
>How about tidying up the rc pattern throughout the function?

I think since this is an actual fix, any tidying up can come later.

Thanks,
Davidlohr

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

* Re: [PATCH] cxl/pci: Fix potential bogus return value upon successful probing
  2024-11-15 16:49   ` Davidlohr Bueso
@ 2024-11-15 19:32     ` Ira Weiny
  0 siblings, 0 replies; 5+ messages in thread
From: Ira Weiny @ 2024-11-15 19:32 UTC (permalink / raw)
  To: Davidlohr Bueso, Alison Schofield
  Cc: dave.jiang, dan.j.williams, vishal.l.verma, ira.weiny, linux-cxl

Davidlohr Bueso wrote:
> On Thu, 14 Nov 2024, Alison Schofield wrote:\n
> >This can be:
> >
> >	if (cxl_pci_ras_unmask(pdev))
> >		dev_dbg(&pdev->dev, "No RAS reporting unmasked\n");
> 
> Yeah, it later occured to me that this was better. Will send a v2.
> 
> >
> >There are a bunch that follow this pattern in that function, mostly in
> >the pmu_count loop.
> >
> >How about tidying up the rc pattern throughout the function?
> 
> I think since this is an actual fix, any tidying up can come later.

Yea that can come later.  Sorry if I implied differently.
Ira

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

end of thread, other threads:[~2024-11-15 19:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-14 21:34 [PATCH] cxl/pci: Fix potential bogus return value upon successful probing Davidlohr Bueso
2024-11-14 23:34 ` Fan Ni
2024-11-15  2:56 ` Alison Schofield
2024-11-15 16:49   ` Davidlohr Bueso
2024-11-15 19:32     ` Ira Weiny

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.