Message ID | 1668675039-21138-1-git-send-email-zhangchangzhong@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp283434wrr; Thu, 17 Nov 2022 00:40:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf5YRGntAHPcJRXAXi2pR+scoj317mJCjnojOgrcSylOTAbdHmbH+2vHG8E71qxHXkbKtp2m X-Received: by 2002:aa7:d844:0:b0:458:fa8f:f82c with SMTP id f4-20020aa7d844000000b00458fa8ff82cmr1232369eds.246.1668674450660; Thu, 17 Nov 2022 00:40:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668674450; cv=none; d=google.com; s=arc-20160816; b=KAnxZaYcYVDnQy3G6FdwIM8FGGvQB1dFS3PMEF7eun+/govNT1ixYFpmJLxXXjcw1K zUe1Red6NNHtCDEJPJg2AMfK2s2RXiCYMrUlbVEZiLhoh90KoGgMIVzt0rXxILTEmD5B SIgDUllZseOWokwILeSWnH+MhQGPSOmRebbEvD7AiDaGkh5vWfjb61o1XQNAE8Pb/994 eSJH6nggN33+KjeoHacYzjV/BldjUCdceTLl3WQUf6ShdAoV2FH2Sx+ZfTZAQSApLtPy U+GyhxHdn1we922eVARkdYFiK7lF97D/iJK9oU/wCdRr3O2uHsXnXbC181MVxSIzoEJ6 NTBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=5cFU56x1RtoqfpDOx4FFHnFFbGvYzh1S81l9SFCnneM=; b=tX5L6hgSoO9+xbzbPYX8M5Ciq2RfP5uIq/VTQRqKP3f0J9I1j4+jVOGU/nIOxocGq0 k5HBqyZ3vlz3npadnYv5Z1ucBwaJi6pk7SbMhGjt4AoBbgjKHgi0zqix74ZCR/kXJHzg E3IvSbjExxQeJlDIj8FPelbCjw9KRISSRohjNuaccnKY0qZXHGaKF3Db8NTm1lOrwu/S uKPOHFHRhJSw5bAbL09pysn2fb/XXCWKa4dFYlUKEBqaOqs4fpeIRioHzLoOkhdDyXaa 55Ny0GwHnn5TvYbeKAKzp2HgIl+iiRmx+M44n633XQiuiy3eu4w2+rSnsCTYniN+xMIh ixSw== 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m25-20020aa7c2d9000000b004513abe8f74si375601edp.249.2022.11.17.00.40.27; Thu, 17 Nov 2022 00:40:50 -0800 (PST) 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; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239537AbiKQIag (ORCPT <rfc822;anhang610@gmail.com> + 99 others); Thu, 17 Nov 2022 03:30:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229931AbiKQIad (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 17 Nov 2022 03:30:33 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52EE5716F5; Thu, 17 Nov 2022 00:30:32 -0800 (PST) Received: from dggpeml500025.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NCY4x4CrtzRpG7; Thu, 17 Nov 2022 16:30:09 +0800 (CST) Received: from dggpeml500006.china.huawei.com (7.185.36.76) by dggpeml500025.china.huawei.com (7.185.36.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 17 Nov 2022 16:30:30 +0800 Received: from localhost.localdomain (10.175.112.70) by dggpeml500006.china.huawei.com (7.185.36.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 17 Nov 2022 16:30:29 +0800 From: Zhang Changzhong <zhangchangzhong@huawei.com> To: <GR-Linux-NIC-Dev@marvell.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, "Paolo Abeni" <pabeni@redhat.com>, Jeff Garzik <jeff@garzik.org>, Ron Mercer <ron.mercer@qlogic.com> CC: Zhang Changzhong <zhangchangzhong@huawei.com>, <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH net] net/qla3xxx: fix potential memleak in ql3xxx_send() Date: Thu, 17 Nov 2022 16:50:38 +0800 Message-ID: <1668675039-21138-1-git-send-email-zhangchangzhong@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.112.70] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500006.china.huawei.com (7.185.36.76) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,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?1749731980986725059?= X-GMAIL-MSGID: =?utf-8?q?1749731980986725059?= |
Series |
[net] net/qla3xxx: fix potential memleak in ql3xxx_send()
|
|
Commit Message
Zhang Changzhong
Nov. 17, 2022, 8:50 a.m. UTC
The ql3xxx_send() returns NETDEV_TX_OK without freeing skb in error
handling case, add dev_kfree_skb_any() to fix it.
Fixes: bd36b0ac5d06 ("qla3xxx: Add support for Qlogic 4032 chip.")
Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com>
---
drivers/net/ethernet/qlogic/qla3xxx.c | 1 +
1 file changed, 1 insertion(+)
Comments
On Thu, Nov 17, 2022 at 04:50:38PM +0800, Zhang Changzhong wrote: > The ql3xxx_send() returns NETDEV_TX_OK without freeing skb in error > handling case, add dev_kfree_skb_any() to fix it. Can you please remind me why should it release? There are no paths in ql3xxx_send() that release skb. Thanks > > Fixes: bd36b0ac5d06 ("qla3xxx: Add support for Qlogic 4032 chip.") > Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com> > --- > drivers/net/ethernet/qlogic/qla3xxx.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c > index 76072f8..0d57ffc 100644 > --- a/drivers/net/ethernet/qlogic/qla3xxx.c > +++ b/drivers/net/ethernet/qlogic/qla3xxx.c > @@ -2471,6 +2471,7 @@ static netdev_tx_t ql3xxx_send(struct sk_buff *skb, > skb_shinfo(skb)->nr_frags); > if (tx_cb->seg_count == -1) { > netdev_err(ndev, "%s: invalid segment count!\n", __func__); > + dev_kfree_skb_any(skb); > return NETDEV_TX_OK; > } > > -- > 2.9.5 >
On 2022/11/17 19:38, Leon Romanovsky wrote: > On Thu, Nov 17, 2022 at 04:50:38PM +0800, Zhang Changzhong wrote: >> The ql3xxx_send() returns NETDEV_TX_OK without freeing skb in error >> handling case, add dev_kfree_skb_any() to fix it. > > Can you please remind me why should it release? > There are no paths in ql3xxx_send() that release skb. > > Thanks > If ql_send_map() returns NETDEV_TX_OK, the packet is sent, and ql_process_mac_tx_intr() releases tx_cb->skb. However, the skb cannot be released in this error path. Thanks, Changzhong >> >> Fixes: bd36b0ac5d06 ("qla3xxx: Add support for Qlogic 4032 chip.") >> Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com> >> --- >> drivers/net/ethernet/qlogic/qla3xxx.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c >> index 76072f8..0d57ffc 100644 >> --- a/drivers/net/ethernet/qlogic/qla3xxx.c >> +++ b/drivers/net/ethernet/qlogic/qla3xxx.c >> @@ -2471,6 +2471,7 @@ static netdev_tx_t ql3xxx_send(struct sk_buff *skb, >> skb_shinfo(skb)->nr_frags); >> if (tx_cb->seg_count == -1) { >> netdev_err(ndev, "%s: invalid segment count!\n", __func__); >> + dev_kfree_skb_any(skb); >> return NETDEV_TX_OK; >> } >> >> -- >> 2.9.5 >> > . >
Hello: This patch was applied to netdev/net.git (master) by Jakub Kicinski <kuba@kernel.org>: On Thu, 17 Nov 2022 16:50:38 +0800 you wrote: > The ql3xxx_send() returns NETDEV_TX_OK without freeing skb in error > handling case, add dev_kfree_skb_any() to fix it. > > Fixes: bd36b0ac5d06 ("qla3xxx: Add support for Qlogic 4032 chip.") > Signed-off-by: Zhang Changzhong <zhangchangzhong@huawei.com> > --- > drivers/net/ethernet/qlogic/qla3xxx.c | 1 + > 1 file changed, 1 insertion(+) Here is the summary with links: - [net] net/qla3xxx: fix potential memleak in ql3xxx_send() https://git.kernel.org/netdev/net/c/62a7311fb96c You are awesome, thank you!
diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c index 76072f8..0d57ffc 100644 --- a/drivers/net/ethernet/qlogic/qla3xxx.c +++ b/drivers/net/ethernet/qlogic/qla3xxx.c @@ -2471,6 +2471,7 @@ static netdev_tx_t ql3xxx_send(struct sk_buff *skb, skb_shinfo(skb)->nr_frags); if (tx_cb->seg_count == -1) { netdev_err(ndev, "%s: invalid segment count!\n", __func__); + dev_kfree_skb_any(skb); return NETDEV_TX_OK; }