From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7B51C1DF740; Wed, 6 Nov 2024 12:21:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730895715; cv=none; b=Vn+qPFmzc666uFiPXT0rrVsHtbWutQr9Ov1ynwh7Lct0sHLD6DYHlBdbPvJz9rL5rzuOYnQUYzI8VwJ2HLxysxM7PZViGj8ouQ4qirK36vqQ5ZIYRsRcYUR1THCx2cFC+7EFj2w9MNkVxB73p29cQKPUdGp6EMeKSjynSwyrANI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730895715; c=relaxed/simple; bh=f5VShkQ6aM0s/iKxdXrpJab0j6gr9vpQc27BtoARLWs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=E34wgMux3BB8Z6ilB1RHOhinEKyiXL6cbmr301/e2+fe3/xJ407mFhp834olnjtic2d8F+PPLlGVxzwyDJsk2jbVXkL3D0RVPtxg/nxRimpUa+9x+iJVelqwtVKteVOArSlIW10m/AhjRnViBmUTUGj9kAd+80Bm3h5LsmM459A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=t9/7fViG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="t9/7fViG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 015E4C4CECD; Wed, 6 Nov 2024 12:21:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1730895715; bh=f5VShkQ6aM0s/iKxdXrpJab0j6gr9vpQc27BtoARLWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t9/7fViG+gSIbRf1Ri0W4GZXvN0n746bUvzIovIr1xSCefV1UvqfoYiPOf0vGSG8s lmpWSZzsDy6Bf1fCjshS4J4hNNrl1v9yzb+0gvGZXO1GQ6XoMmWVfbsERw7gVLehx9 HCTkNGdNhmallqCOGmIrW/wuavi7Ruz26lTAsX6s= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Wang Hai , Simon Horman , Kalesh AP , Andrew Lunn , Sasha Levin Subject: [PATCH 4.19 311/350] be2net: fix potential memory leak in be_xmit() Date: Wed, 6 Nov 2024 13:03:59 +0100 Message-ID: <20241106120328.456768331@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106120320.865793091@linuxfoundation.org> References: <20241106120320.865793091@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Wang Hai [ Upstream commit e4dd8bfe0f6a23acd305f9b892c00899089bd621 ] The be_xmit() returns NETDEV_TX_OK without freeing skb in case of be_xmit_enqueue() fails, add dev_kfree_skb_any() to fix it. Fixes: 760c295e0e8d ("be2net: Support for OS2BMC.") Signed-off-by: Wang Hai Reviewed-by: Simon Horman Reviewed-by: Kalesh AP Message-ID: <20241015144802.12150-1-wanghai38@huawei.com> Signed-off-by: Andrew Lunn Signed-off-by: Sasha Levin --- drivers/net/ethernet/emulex/benet/be_main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index d0d9a420f557e..8215bd1ca022f 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -1386,10 +1386,8 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev) be_get_wrb_params_from_skb(adapter, skb, &wrb_params); wrb_cnt = be_xmit_enqueue(adapter, txo, skb, &wrb_params); - if (unlikely(!wrb_cnt)) { - dev_kfree_skb_any(skb); - goto drop; - } + if (unlikely(!wrb_cnt)) + goto drop_skb; /* if os2bmc is enabled and if the pkt is destined to bmc, * enqueue the pkt a 2nd time with mgmt bit set. @@ -1398,7 +1396,7 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev) BE_WRB_F_SET(wrb_params.features, OS2BMC, 1); wrb_cnt = be_xmit_enqueue(adapter, txo, skb, &wrb_params); if (unlikely(!wrb_cnt)) - goto drop; + goto drop_skb; else skb_get(skb); } @@ -1412,6 +1410,8 @@ static netdev_tx_t be_xmit(struct sk_buff *skb, struct net_device *netdev) be_xmit_flush(adapter, txo); return NETDEV_TX_OK; +drop_skb: + dev_kfree_skb_any(skb); drop: tx_stats(txo)->tx_drv_drops++; /* Flush the already enqueued tx requests */ -- 2.43.0