[PATCH v2] net: amd: Fix link leak when verifying config failed

Gencen Gan posted 1 patch 2 years, 8 months ago
There is a newer version of this series
drivers/net/ethernet/amd/nmclan_cs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] net: amd: Fix link leak when verifying config failed
Posted by Gencen Gan 2 years, 8 months ago
From: Gan Gecen <gangecen@hust.edu.cn>

After failing to verify configuration, it returns directly without 
releasing link, which may cause memory leak.

Signed-off-by: Gan Gecen <gangecen@hust.edu.cn>
---
v1->v2: Fix the whitespace-damaged bug. 
 drivers/net/ethernet/amd/nmclan_cs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/amd/nmclan_cs.c b/drivers/net/ethernet/amd/nmclan_cs.c
index 823a329a921f..0dd391c84c13 100644
--- a/drivers/net/ethernet/amd/nmclan_cs.c
+++ b/drivers/net/ethernet/amd/nmclan_cs.c
@@ -651,7 +651,7 @@ static int nmclan_config(struct pcmcia_device *link)
     } else {
       pr_notice("mace id not found: %x %x should be 0x40 0x?9\n",
 		sig[0], sig[1]);
-      return -ENODEV;
+      goto failed;
     }
   }
 
-- 
2.34.1
Re: [PATCH v2] net: amd: Fix link leak when verifying config failed
Posted by Paolo Abeni 2 years, 8 months ago
Hi,

On Wed, 2023-04-19 at 14:58 +0800, Gencen Gan wrote:
> From: Gan Gecen <gangecen@hust.edu.cn>
> 
> After failing to verify configuration, it returns directly without 
> releasing link, which may cause memory leak.
> 
> Signed-off-by: Gan Gecen <gangecen@hust.edu.cn>

Please include a suitable Fixes tag and specify the target tree in the
subj - see the documentation for the details.

More importantly, skimming over the relevant code I think that at least
a netdev is still leaked in the relevant error path.

Generally speaking the whole code of this driver is quite "suboptimal"
and looks unmainatained since at least ~15y, just receiving tree-wide
related changes.

I'm wondering if we could simply remove the whole driver?

Thanks

Paolo