diff mbox series

[net] 3c589_cs: Fix an error handling path in tc589_probe()

Message ID d8593ae867b24c79063646e36f9b18b0790107cb.1684575975.git.christophe.jaillet@wanadoo.fr (mailing list archive)
State Accepted
Commit 640bf95b2c7c2981fb471acdafbd3e0458f8390d
Delegated to: Netdev Maintainers
Headers show
Series [net] 3c589_cs: Fix an error handling path in tc589_probe() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 9 this patch: 9
netdev/cc_maintainers warning 5 maintainers not CCed: geoff@infradead.org wsa+renesas@sang-engineering.com mw@semihalf.com khalasa@piap.pl leon@kernel.org
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 9 this patch: 9
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 23 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Christophe JAILLET May 20, 2023, 9:48 a.m. UTC
Should tc589_config() fail, some resources need to be released as already
done in the remove function.

Fixes: 15b99ac17295 ("[PATCH] pcmcia: add return value to _config() functions")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/net/ethernet/3com/3c589_cs.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Comments

Simon Horman May 22, 2023, 12:34 p.m. UTC | #1
On Sat, May 20, 2023 at 11:48:55AM +0200, Christophe JAILLET wrote:
> Should tc589_config() fail, some resources need to be released as already
> done in the remove function.
> 
> Fixes: 15b99ac17295 ("[PATCH] pcmcia: add return value to _config() functions")

That commit is probably going back far enough, but I actually
suspect the problem has been there since the beginning of git history.

> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Simon Horman <simon.horman@corigine.com>
Christophe JAILLET May 22, 2023, 5:18 p.m. UTC | #2
Le 22/05/2023 à 14:34, Simon Horman a écrit :
> On Sat, May 20, 2023 at 11:48:55AM +0200, Christophe JAILLET wrote:
>> Should tc589_config() fail, some resources need to be released as already
>> done in the remove function.
>>
>> Fixes: 15b99ac17295 ("[PATCH] pcmcia: add return value to _config() functions")
> 
> That commit is probably going back far enough, but I actually
> suspect the problem has been there since the beginning of git history.

In fact, before that commit, the probe was always returning 0, so there 
was no need for an error handling path.

FYI, commit 15b99ac17295 ("[PATCH] pcmcia: add return value to _config() 
functions") messed up many drivers for the same reason.
I sent a few patches to see if there was an interest to fix these 
(really) old drivers, most linked with pcmcia which seems to slowly be 
removed from the kernel.

So I'm a bit unsure if fixing it really matters.
Let see if I collect some other R-b tags for the other patches.

CJ

> 
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> 
> Reviewed-by: Simon Horman <simon.horman@corigine.com>
> 
> 
>
patchwork-bot+netdevbpf@kernel.org May 23, 2023, 2:30 a.m. UTC | #3
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Sat, 20 May 2023 11:48:55 +0200 you wrote:
> Should tc589_config() fail, some resources need to be released as already
> done in the remove function.
> 
> Fixes: 15b99ac17295 ("[PATCH] pcmcia: add return value to _config() functions")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/net/ethernet/3com/3c589_cs.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)

Here is the summary with links:
  - [net] 3c589_cs: Fix an error handling path in tc589_probe()
    https://git.kernel.org/netdev/net/c/640bf95b2c7c

You are awesome, thank you!
Simon Horman May 23, 2023, 8:42 a.m. UTC | #4
On Mon, May 22, 2023 at 07:18:29PM +0200, Christophe JAILLET wrote:
> Le 22/05/2023 à 14:34, Simon Horman a écrit :
> > On Sat, May 20, 2023 at 11:48:55AM +0200, Christophe JAILLET wrote:
> > > Should tc589_config() fail, some resources need to be released as already
> > > done in the remove function.
> > > 
> > > Fixes: 15b99ac17295 ("[PATCH] pcmcia: add return value to _config() functions")
> > 
> > That commit is probably going back far enough, but I actually
> > suspect the problem has been there since the beginning of git history.
> 
> In fact, before that commit, the probe was always returning 0, so there was
> no need for an error handling path.

Sure. But resources could still leak, as far as I can tell.
Adding a return value provided a mechanism to fix such leaks.
But wasn't done (until now). Just my 2c worth.


> FYI, commit 15b99ac17295 ("[PATCH] pcmcia: add return value to _config()
> functions") messed up many drivers for the same reason.
> I sent a few patches to see if there was an interest to fix these (really)
> old drivers, most linked with pcmcia which seems to slowly be removed from
> the kernel.
> 
> So I'm a bit unsure if fixing it really matters.
> Let see if I collect some other R-b tags for the other patches.

Yes, let's see.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/3com/3c589_cs.c b/drivers/net/ethernet/3com/3c589_cs.c
index 82f94b1635bf..5267e9dcd87e 100644
--- a/drivers/net/ethernet/3com/3c589_cs.c
+++ b/drivers/net/ethernet/3com/3c589_cs.c
@@ -195,6 +195,7 @@  static int tc589_probe(struct pcmcia_device *link)
 {
 	struct el3_private *lp;
 	struct net_device *dev;
+	int ret;
 
 	dev_dbg(&link->dev, "3c589_attach()\n");
 
@@ -218,7 +219,15 @@  static int tc589_probe(struct pcmcia_device *link)
 
 	dev->ethtool_ops = &netdev_ethtool_ops;
 
-	return tc589_config(link);
+	ret = tc589_config(link);
+	if (ret)
+		goto err_free_netdev;
+
+	return 0;
+
+err_free_netdev:
+	free_netdev(dev);
+	return ret;
 }
 
 static void tc589_detach(struct pcmcia_device *link)