From nobody Wed Nov 27 04:51:02 2024 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9060B946C; Sat, 12 Oct 2024 11:05:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728731130; cv=none; b=Yxd9Tpww0EfIV6hHGXybgMqin7mEloyWLbTMLgpki5w0EvYBS9T1XqN0nOUOvFOqpVIy/zf77CczIhG0/d0AwR58f4zM3Rf5ctV89KYjMWsLEicqGCG8ZxuyVoZ6JyNjJrCZTXFa/VeosnLrlAr0931XjJvg4Vr7TkmAxwUY3ko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728731130; c=relaxed/simple; bh=OWLTX2rU5T/lSpyqyqmsOut31D4sHI4lzST5s2bgNRo=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=VDkOl8PzsmRJDeHRFt6vseZCCJTpLflLKGERq8AmrTUCZXgqgA/QzX/2psJJCuOzh63m1TAWqLDapeeE88tmmSfd8yoVmTO0P8dxzC/gqucyfTMa2uxZzcBvNvD7DTC9gEDeYylCR0Pi2mIuLdzkI06iXA5kJNFUNSrUHmApMfY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4XQgcG5mLGz20ptN; Sat, 12 Oct 2024 19:04:30 +0800 (CST) Received: from kwepemm600001.china.huawei.com (unknown [7.193.23.3]) by mail.maildlp.com (Postfix) with ESMTPS id 9816D1A0188; Sat, 12 Oct 2024 19:05:10 +0800 (CST) 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_256_GCM_SHA384) id 15.1.2507.39; Sat, 12 Oct 2024 19:05:09 +0800 From: Wang Hai To: , , , , , , , CC: , , Subject: [PATCH v2 net] net: ethernet: aeroflex: fix potential memory leak in greth_start_xmit_gbit() Date: Sat, 12 Oct 2024 19:04:34 +0800 Message-ID: <20241012110434.49265-1-wanghai38@huawei.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600001.china.huawei.com (7.193.23.3) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The greth_start_xmit_gbit() returns NETDEV_TX_OK without freeing skb in case of skb->len being too long, add dev_kfree_skb() to fix it. Fixes: d4c41139df6e ("net: Add Aeroflex Gaisler 10/100/1G Ethernet MAC driv= er") Signed-off-by: Wang Hai Reviewed-by: Gerhard Engleder --- v1->v2: Using dev_kfree_skb() in error handling. drivers/net/ethernet/aeroflex/greth.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/aeroflex/greth.c b/drivers/net/ethernet/a= eroflex/greth.c index 27af7746d645..adf6f67c5fcb 100644 --- a/drivers/net/ethernet/aeroflex/greth.c +++ b/drivers/net/ethernet/aeroflex/greth.c @@ -484,7 +484,7 @@ greth_start_xmit_gbit(struct sk_buff *skb, struct net_d= evice *dev) =20 if (unlikely(skb->len > MAX_FRAME_SIZE)) { dev->stats.tx_errors++; - goto out; + goto len_error; } =20 /* Save skb pointer. */ @@ -575,6 +575,7 @@ greth_start_xmit_gbit(struct sk_buff *skb, struct net_d= evice *dev) map_error: if (net_ratelimit()) dev_warn(greth->dev, "Could not create TX DMA mapping\n"); +len_error: dev_kfree_skb(skb); out: return err; --=20 2.17.1