From patchwork Fri Nov 18 12:37:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Changzhong X-Patchwork-Id: 22295 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp161822wrr; Fri, 18 Nov 2022 04:19:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf6CyLC2QM0qnpoGivtuy6Cyu433hAXM9OzbCTWiee/4ngvqKoX7sPCT8Z5aZTZSgAh1BiQu X-Received: by 2002:aa7:c04f:0:b0:45c:f13b:4b96 with SMTP id k15-20020aa7c04f000000b0045cf13b4b96mr5955230edo.129.1668773984635; Fri, 18 Nov 2022 04:19:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668773984; cv=none; d=google.com; s=arc-20160816; b=W/ZmCNgzvqp8XY109fnwM6FhvRta/Rmk5URK0Etd2j6guZeLzlzbJosihnRqs2Lla8 YWTS3sxXVdHyt1YOKK3E0kf0BQWCd3n3NVWSXhCt0kkviVjSjISKUVgX8S1W3OX+E/DV 2S+XxMLfr/Z/U5otUhETmXqxnqDnUAITZU+NmWvZQU72uPG2LtJzjCNJhJ7EkvZNHEy/ myDDoCBWKmLArq/vTBDhuooFTCF9FOSP118ZvqaGDgTxkqgqQAx8vR+qVH8QKuea8ugV H6P7dYWLh3VsZ42OUf5/D5MZLLvf92woZUC+/kYOeBmOVpF3BFRBfHjj9nkJbB3OuEIK jK6Q== 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=D/4scOboEBmy7nzcraXfFrXjPuq2wVokmslmMD2XfC8=; b=bEDXyr0L9sv2Ji6yPhjB9XhJBM0NtoDmcb1v8TXKpRsZfLkpfhJhkV0dFF/clwa2dY L4Zxxkb453GGYiYWOK8qjLJRUUlR/SpOetLrtls6QL4zD/dah2F96UOrW0BDjFBUi2D8 hyaTFALy6sR+i0G/p6MNfkRRXVonJf7m6mYMej/oHXaDLIl0dqT/1aJoUzX5FjooPwAU ZhWmHIuAQF8ez9zbVGJl7/pwT5xmJ8zjdBRR3SJU0U0fGP11KDhtEcRg//0DOV9OtDT1 ujBx/9DdWmoONhnqOXk9TmjOcTE6HbRGVBqeOZ3K97LVYLPHeX9m2HCDmUwqFyovJey8 ipPQ== 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 tb26-20020a1709078b9a00b00741a16e8562si2636559ejc.826.2022.11.18.04.19.19; Fri, 18 Nov 2022 04:19:44 -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 S241787AbiKRMSR (ORCPT + 99 others); Fri, 18 Nov 2022 07:18:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241837AbiKRMR6 (ORCPT ); Fri, 18 Nov 2022 07:17:58 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0376A976D6; Fri, 18 Nov 2022 04:17:53 -0800 (PST) Received: from dggpeml500025.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NDG0n0ZspzqSXF; Fri, 18 Nov 2022 20:14:01 +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; Fri, 18 Nov 2022 20:17:51 +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; Fri, 18 Nov 2022 20:17:50 +0800 From: Zhang Changzhong To: Jesse Brandeburg , Tony Nguyen , "David S. Miller" , "Eric Dumazet" , Jakub Kicinski , Paolo Abeni , Jeff Kirsher , "Alexander Duyck" CC: Zhang Changzhong , , Subject: [PATCH net] fm10k: fix potential memleak in fm10k_xmit_frame() Date: Fri, 18 Nov 2022 20:37:27 +0800 Message-ID: <1668775048-22031-1-git-send-email-zhangchangzhong@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.175.112.70] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749836349364990687?= X-GMAIL-MSGID: =?utf-8?q?1749836349364990687?= The fm10k_xmit_frame() returns NETDEV_TX_OK without freeing skb in error handling case, add dev_kfree_skb() to fix it. Compile tested only. Fixes: b101c9626477 ("fm10k: Add transmit and receive fastpath and interrupt handlers") Signed-off-by: Zhang Changzhong Reviewed-by: Alexander Duyck --- drivers/net/ethernet/intel/fm10k/fm10k_netdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c index 2cca9e8..c7b672a 100644 --- a/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c +++ b/drivers/net/ethernet/intel/fm10k/fm10k_netdev.c @@ -531,8 +531,10 @@ static netdev_tx_t fm10k_xmit_frame(struct sk_buff *skb, struct net_device *dev) return NETDEV_TX_OK; /* make sure there is enough room to move the ethernet header */ - if (unlikely(!pskb_may_pull(skb, VLAN_ETH_HLEN))) + if (unlikely(!pskb_may_pull(skb, VLAN_ETH_HLEN))) { + dev_kfree_skb(skb); return NETDEV_TX_OK; + } /* verify the skb head is not shared */ err = skb_cow_head(skb, 0);