From patchwork Thu Nov 17 06:55:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Hai X-Patchwork-Id: 21430 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp213673wrr; Wed, 16 Nov 2022 20:50:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf5FJVvQe0wON7WEv505fd3BUXibWV3Q1FCt7pJH6tdMyVvDcx18+kXcQjkUinAooW6N+XxW X-Received: by 2002:a17:906:2b56:b0:78d:b6ea:174e with SMTP id b22-20020a1709062b5600b0078db6ea174emr757669ejg.95.1668660656324; Wed, 16 Nov 2022 20:50:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668660656; cv=none; d=google.com; s=arc-20160816; b=CIvX+kDfsINEMg+rY2kusJXzH5nQGIuOBFkwzfipATLjZQE3Cwfz2T8oRPB9946tSj FsGW//+7slNdFT4wejLoDQeh/JKVzpBLE8WWZx5TjHvA7kut4UshfI5rCPM6iaOreVBf lzw5R2b81snMUKTaU0w2UlVyY39xs+qlDB7TKGXMCqUt53OUYgD1YD9u/NX7JqOYDD7K DbNuoCtIrIho7+qt1ywAsiO87uLBYIFf04K0FDLwtlOFFZNZHpY5mUfQiz3LuvLtCU/O FOESQsm9bLV4DHYCGjrniXZnujzy7m6UBEirIZjMyg4vJrc1on2fw03mQ3VABDpQ+CVz 10zQ== 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=4MXSQS8oJR03o7/glzzP0+B3TYYV7QMalQ+lB1+Egh4=; b=BTjo8BTQ5AwSK0fq08fQ7vJBVOc1P0UO1kAJQICdVO+WkaE/u/gCsuMCgpquNTyrw3 b9LKJsnC1e56pv7PR8nRv9tvcYh6CJwS7aP/HMCf8l5sDD70MhJJcqDeUBLYJ0tOThj+ 4kgs8yGVIA46u61qu0t40U5foksWid/B/9xNZ+lZ/wTf5nahluRWkXHr8rVlKg8Rymcu x4EDA+LdioLGjxVAPOMm4pU5PZoVKkAn5/9e3SGBA5avr8uIuQIx+Fb9M4gQS0my4PEI NzYHsMdwkAxgTcDHccOncHqvLgAtLnAnarSCiRhC+EU/P+McTcg9boRPl1ghkxwoNRIk d/WA== 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 ke15-20020a17090798ef00b007a6384d506csi12715625ejc.643.2022.11.16.20.50.33; Wed, 16 Nov 2022 20:50:56 -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 S239199AbiKQEdx (ORCPT + 99 others); Wed, 16 Nov 2022 23:33:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233363AbiKQEds (ORCPT ); Wed, 16 Nov 2022 23:33:48 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C5B92704; Wed, 16 Nov 2022 20:33:47 -0800 (PST) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NCRqm6CD7zRpGY; Thu, 17 Nov 2022 12:33:24 +0800 (CST) Received: from kwepemm600001.china.huawei.com (7.193.23.3) by dggemv711-chm.china.huawei.com (10.1.198.66) 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 12:33:44 +0800 Received: from huawei.com (10.175.113.133) by kwepemm600001.china.huawei.com (7.193.23.3) 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 12:33:43 +0800 From: Wang Hai To: , , , , , , CC: , Subject: [PATCH net] net: pch_gbe: fix potential memleak in pch_gbe_tx_queue() Date: Thu, 17 Nov 2022 14:55:27 +0800 Message-ID: <20221117065527.71103-1-wanghai38@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.175.113.133] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600001.china.huawei.com (7.193.23.3) 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?1749717516680206805?= X-GMAIL-MSGID: =?utf-8?q?1749717516680206805?= In pch_gbe_xmit_frame(), NETDEV_TX_OK will be returned whether pch_gbe_tx_queue() sends data successfully or not, so pch_gbe_tx_queue() needs to free skb before returning. But pch_gbe_tx_queue() returns without freeing skb in case of dma_map_single() fails. Add dev_kfree_skb_any() to fix it. Fixes: 77555ee72282 ("net: Add Gigabit Ethernet driver of Topcliff PCH") Signed-off-by: Wang Hai --- drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c index 3f2c30184752..c9ae47128a07 100644 --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c @@ -1143,6 +1143,7 @@ static void pch_gbe_tx_queue(struct pch_gbe_adapter *adapter, buffer_info->dma = 0; buffer_info->time_stamp = 0; tx_ring->next_to_use = ring_num; + dev_kfree_skb_any(skb); return; } buffer_info->mapped = true;