Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1559986rwb; Wed, 16 Nov 2022 21:01:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf4YHxMtDRjx5A1cMmyPFzGs94E8qFDbaYDTIKmESO6zDg9BuGfZvr8H2Xj9yiaiqitH/ZJ5 X-Received: by 2002:a17:907:8d02:b0:7ad:f43a:cb07 with SMTP id tc2-20020a1709078d0200b007adf43acb07mr741701ejc.562.1668661291001; Wed, 16 Nov 2022 21:01:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668661290; cv=none; d=google.com; s=arc-20160816; b=rMNOYUMOMBXlPLR8+0aownKUZwsALtg885zxl8ri9hvecFdZJjOp3hDzaqbaUPVHUI E9IV+27wfzuc0MZBUWGBmUMoUzNF5ceZY/pmqhtYF+JqICOUtHNe+NARURLr8If+SrSo XiPUtjryX/b7RXaA5mC43hRKBZZYOzcXeEFT0HTTMUsasA15ul1D9oa6Jd1ekuROvHgu ps0UDQKGvdVTfKvP8kH64mkHLHkxId5YIlXRqrH9Lw2soqGdI+Y4Y8gvPQZylQ2RjKUU xHnI33nM4nQHHrtA2y7d70vnJq6BU11OxQ9S39FOk0Oc9tMa0VwcFRL6iS0OJPieK/Na p+yQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i9-20020a50fc09000000b00461a9ddbda7si71056edr.90.2022.11.16.21.01.09; Wed, 16 Nov 2022 21:01:30 -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 + 91 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 Content-Type: text/plain 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 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; -- 2.17.1