Message ID | dc114193121c52c8fa3779e49bdd99d4b41344a9.1667077009.git.christophe.jaillet@wanadoo.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1505247wru; Sat, 29 Oct 2022 14:02:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6AyrVzoTzd4iJcgwejxmfBVAlZJck4xnI2ElcAyE8ccuDNcmeckk/xrimc22XReDz0GNb6 X-Received: by 2002:a05:6402:2794:b0:461:d60c:30c7 with SMTP id b20-20020a056402279400b00461d60c30c7mr5726673ede.392.1667077332775; Sat, 29 Oct 2022 14:02:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667077332; cv=none; d=google.com; s=arc-20160816; b=XfV/kPUMzBTzdjPD3yP4msXAexsSbK1/3NLiEeLvMuMg2KMBJk2sv0QeE+on0n9/bL lFwpPDYv27fivBfm/aj5B1wA/vAagCfi7sSq1hoZa6ORQUoqFezQu3kjg6hnD0gi6ByH gejYhTYySuhVSOHlxPuCHFK14ArUGbXYfFuq5ZGKfAEQS6TuFr6dm0KJ/k6XFvwRJunf J7mAgLwE96ho+x2upjEx0lhiyAtlgCS/liWvUFVSUCch1bTN0Rmheehmfx5PrV0TmJOi +yjGere9PJ8RAAJG/9YEVyZMzwOdLD3MpKNGRkvGxgp2XdDPivWARia3ChiOf8vxW4w4 TKlQ== 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; bh=3jWAaN0vdIgU4cuIoS8UYlJ14ZxOLYaxrGdjaFFzRoQ=; b=u/vNxUEMlocbV+++cV6s6lkt0gbuJX9oi7/sVgcy1sLcyQ3zrdn+cMXF66zUOFGpcR D6TQ3XTTgJMpptD95EBGT64ho1rI0oSk6vl+K+ZicC4Ihe1U5Pe+tbibkdjxJeM1Ta/k FeA54g2YKx6B6RO8pFkTPs6S6XaH+7iNKAXup38mrrCuvf35DTP9vJ2ORKDolhgG2QoZ kkRFjvcIU7h9j91HTykG2gp7Eq2x/UdlbG3r5Ct6LhBEB2FExyI6y4mlI7Xi/xyCqh7/ KhvpDVXUDlN2g3I1NApXWypYVr4PEwaMXV4WhsQ5cL/SxoP7iB1jQ+hHAz2SS47ty1b5 mX4A== ARC-Authentication-Results: i=1; mx.google.com; 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 y9-20020a056402440900b00461b2c3c4acsi3178832eda.515.2022.10.29.14.01.49; Sat, 29 Oct 2022 14:02:12 -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; 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 S229456AbiJ2U5Z (ORCPT <rfc822;ezelljr.billy@gmail.com> + 99 others); Sat, 29 Oct 2022 16:57:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbiJ2U5U (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 29 Oct 2022 16:57:20 -0400 Received: from smtp.smtpout.orange.fr (smtp-17.smtpout.orange.fr [80.12.242.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2622233E28 for <linux-kernel@vger.kernel.org>; Sat, 29 Oct 2022 13:57:18 -0700 (PDT) Received: from pop-os.home ([86.243.100.34]) by smtp.orange.fr with ESMTPA id ostGo0hePez1rostGo2ToZ; Sat, 29 Oct 2022 22:57:15 +0200 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 29 Oct 2022 22:57:15 +0200 X-ME-IP: 86.243.100.34 From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: Edward Cree <ecree.xilinx@gmail.com>, Martin Habets <habetsm.xilinx@gmail.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Jonathan Cooper <jonathan.s.cooper@amd.com> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, netdev@vger.kernel.org Subject: [PATCH] sfc: Fix an error handling path in efx_pci_probe() Date: Sat, 29 Oct 2022 22:57:11 +0200 Message-Id: <dc114193121c52c8fa3779e49bdd99d4b41344a9.1667077009.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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham 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?1748057281369597453?= X-GMAIL-MSGID: =?utf-8?q?1748057281369597453?= |
Series |
sfc: Fix an error handling path in efx_pci_probe()
|
|
Commit Message
Christophe JAILLET
Oct. 29, 2022, 8:57 p.m. UTC
If an error occurs after the first kzalloc() the corresponding memory
allocation is never freed.
Add the missing kfree() in the error handling path, as already done in the
remove() function.
Fixes: 7e773594dada ("sfc: Separate efx_nic memory from net_device memory")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
When 7e773594dada was merged, sfc/ef100.c had the same issue.
But it seems to have been fixed in 98ff4c7c8ac7.
---
drivers/net/ethernet/sfc/efx.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
Comments
Please specify a branch in the subject. This patch should go to net. On Sat, Oct 29, 2022 at 10:57:11PM +0200, Christophe JAILLET wrote: > If an error occurs after the first kzalloc() the corresponding memory > allocation is never freed. > > Add the missing kfree() in the error handling path, as already done in the > remove() function. > > Fixes: 7e773594dada ("sfc: Separate efx_nic memory from net_device memory") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Acked-by: Martin Habets <habetsm.xilinx@gmail.com> > --- > When 7e773594dada was merged, sfc/ef100.c had the same issue. > But it seems to have been fixed in 98ff4c7c8ac7. I agree. > --- > drivers/net/ethernet/sfc/efx.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c > index 054d5ce6029e..0556542d7a6b 100644 > --- a/drivers/net/ethernet/sfc/efx.c > +++ b/drivers/net/ethernet/sfc/efx.c > @@ -1059,8 +1059,10 @@ static int efx_pci_probe(struct pci_dev *pci_dev, > > /* Allocate and initialise a struct net_device */ > net_dev = alloc_etherdev_mq(sizeof(probe_data), EFX_MAX_CORE_TX_QUEUES); > - if (!net_dev) > - return -ENOMEM; > + if (!net_dev) { > + rc = -ENOMEM; > + goto fail0; > + } > probe_ptr = netdev_priv(net_dev); > *probe_ptr = probe_data; > efx->net_dev = net_dev; > @@ -1132,6 +1134,8 @@ static int efx_pci_probe(struct pci_dev *pci_dev, > WARN_ON(rc > 0); > netif_dbg(efx, drv, efx->net_dev, "initialisation failed. rc=%d\n", rc); > free_netdev(net_dev); > + fail0: > + kfree(probe_data); > return rc; > } > > -- > 2.34.1
Hello: This patch was applied to netdev/net.git (master) by Jakub Kicinski <kuba@kernel.org>: On Sat, 29 Oct 2022 22:57:11 +0200 you wrote: > If an error occurs after the first kzalloc() the corresponding memory > allocation is never freed. > > Add the missing kfree() in the error handling path, as already done in the > remove() function. > > Fixes: 7e773594dada ("sfc: Separate efx_nic memory from net_device memory") > Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> > > [...] Here is the summary with links: - sfc: Fix an error handling path in efx_pci_probe() https://git.kernel.org/netdev/net/c/6c412da54c80 You are awesome, thank you!
diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 054d5ce6029e..0556542d7a6b 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c @@ -1059,8 +1059,10 @@ static int efx_pci_probe(struct pci_dev *pci_dev, /* Allocate and initialise a struct net_device */ net_dev = alloc_etherdev_mq(sizeof(probe_data), EFX_MAX_CORE_TX_QUEUES); - if (!net_dev) - return -ENOMEM; + if (!net_dev) { + rc = -ENOMEM; + goto fail0; + } probe_ptr = netdev_priv(net_dev); *probe_ptr = probe_data; efx->net_dev = net_dev; @@ -1132,6 +1134,8 @@ static int efx_pci_probe(struct pci_dev *pci_dev, WARN_ON(rc > 0); netif_dbg(efx, drv, efx->net_dev, "initialisation failed. rc=%d\n", rc); free_netdev(net_dev); + fail0: + kfree(probe_data); return rc; }