Message ID | d8593ae867b24c79063646e36f9b18b0790107cb.1684575975.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp260851vqo; Sat, 20 May 2023 02:53:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4BEs17iUQvmQSW94yEHU/HEK76DhyRlL87w4YXLkCV0ixOcHoXdnWkVRPGQUDoWAT88nxS X-Received: by 2002:a05:6a00:2288:b0:643:aa8d:8cd7 with SMTP id f8-20020a056a00228800b00643aa8d8cd7mr7511079pfe.32.1684576407472; Sat, 20 May 2023 02:53:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684576407; cv=none; d=google.com; s=arc-20160816; b=FsBXUUkpYjz/9BpVFTygz2iyJiPDd6+BokV/m75pVWmmVQ2KQghQ5fwR80Ebl398sk 8ROe/APTbKSzbT93iX3e7xf/WAqyZmc3PlPQarBsuwflj2ze1b7ZJxceDIgd9mtpQkDt iTzWJ01pimuHbvf6/b8ix0imesBsRY2NJuCNBBT3a0Dn8UwfvSMM8/IKX9JDm8mNRs+p zyPJxbjCYCCe6CcMwPmts6rYcI8AcQRKolSQci84T57/xG/deKp2If4haAWHqVr7mQ52 C4ry1WSrkBeHx5EP2VZODzeeJ6t3owfYrpLkdZO2+64PP407hr+auDadCoq5iqVChMo+ jt7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=PFeiTJVHke4bEGuoYNcOkxZOFogPE/KWv3YrygEuprE=; b=r7DkCf9ZSVE1MPdmNIevxTCkPAhevI3zFEe+OsOJCk7MN7ONxyEgHgoZeAkPVHWq8A Eu40DEvoZJjOfFFBUx+b2oCXlOco4MtH8bDmSp5kHrxCwmUYphU0mubMif9XiHsiRVTl mDu7ijVh+Xxehpg2eofXd6Vs4DNiP6hmPlbbZyLZQMShCAVfulrKVevVwgWhKpBPao13 pssBc1uJno+B8VEGUu9+6do0FzguXrNX6YvNQFnwcgQu85GQx+Iu5itX8k9lHUQcrwiv GVzX0PteazteKcuUqgmB4LWfgqd27dMA765wb+OjPmQk6TypESa7Bt05s4GEZbketu6i 856A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=ZZmnYIxh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z13-20020aa7948d000000b0064d3e917a90si1292697pfk.180.2023.05.20.02.53.15; Sat, 20 May 2023 02:53:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=ZZmnYIxh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231417AbjETJtE (ORCPT <rfc822;ahmedalshaiji.dev@gmail.com> + 99 others); Sat, 20 May 2023 05:49:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229946AbjETJtD (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 20 May 2023 05:49:03 -0400 Received: from smtp.smtpout.orange.fr (smtp-25.smtpout.orange.fr [80.12.242.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78773E42 for <linux-kernel@vger.kernel.org>; Sat, 20 May 2023 02:49:01 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id 0JCrqmyLhJVoz0JCrqxvws; Sat, 20 May 2023 11:48:59 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1684576139; bh=PFeiTJVHke4bEGuoYNcOkxZOFogPE/KWv3YrygEuprE=; h=From:To:Cc:Subject:Date; b=ZZmnYIxhy2r+fBlx5gImUrUjp5VJ9heiJfdHbrg1D9u+rGIDidIrJ35WOrhesnvkQ /zVnMJfVC8VgwYqsmlgG8Gq62luUVWWYXiUx+4mGp3YoZdFqxDvbRFtA4FfYU4nIfs UODreIOmfBaKoj71ZRxnIUVzdHzBpU/rzx9shW4BdVf5O6PmM8nHzKYw29XSpNXUFJ uuYmg62rpeDQ4VHEocHUk0njr5LJfzB+VFh6FMaiDDUQrtOOff1sCKLVrJNCHnWq// C1ad6e4+An+BM2jVUL6gMeJL+0o8tDzJhtCWvrrs5iFW6XFzMEXSbld+Z+OsZ9+tYt eM7uYsJZ6D9hg== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 20 May 2023 11:48:59 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Dominik Brodowski <linux@dominikbrodowski.net> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, netdev@vger.kernel.org Subject: [PATCH net] 3c589_cs: Fix an error handling path in tc589_probe() Date: Sat, 20 May 2023 11:48:55 +0200 Message-Id: <d8593ae867b24c79063646e36f9b18b0790107cb.1684575975.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766406390639850500?= X-GMAIL-MSGID: =?utf-8?q?1766406390639850500?= |
Series |
[net] 3c589_cs: Fix an error handling path in tc589_probe()
|
|
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
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>
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> > > >
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!
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 --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)