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 C4342152E1C; Mon, 28 Oct 2024 06:29:05 +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=1730096945; cv=none; b=EOK8cAG7c/9/bhNET+oFsYPW/KeoaJsJYltfcDue929SnRdfIqyoyAMmZDYgOCIfdfm03fFgbKevT18TMntQHrGxyRGIpuMxKwO/Mv4K2OyBwrm+1YYcyaDuZTjCnnBYUoNaK69CRKFN5z/mb2t/bRKVeway1/MA5BUAFjit4Pc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730096945; c=relaxed/simple; bh=lUoMl/E/ZQFG+3DYuz6+RGQM0O0t/PvYt094aZUFvKA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TiAFfA3E7cYJQSjZ4DVZddoGzMkn7GLNslbr1k8GWmCGUW/piMRm6FErG2tz0R0jdG9//ExUvvvm6a2m4JAH/5O0m0LHoKTkjE5WHb+xBTyorSRC55xrhCvq+89DAjK29chfo94kyztJMVVfnwf5ap1qZgAECaWqvPpDCU1G+eU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Lg/pql0p; 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="Lg/pql0p" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D369C4CEC3; Mon, 28 Oct 2024 06:29:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1730096945; bh=lUoMl/E/ZQFG+3DYuz6+RGQM0O0t/PvYt094aZUFvKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Lg/pql0phhtTMVn/h6DDrnk26u+7KYkhjSuKeSSmZbFusqRPdJZ6S8kN+ge58S8B3 8eZOb7ZrbL1CSA0XFFoVhgQT0bpYID60ZyQpeSgwBUXskjSETSjlk0On7AchVK3Cf5 GEYUoGYm1VJ1uwuCVZwi1rzWMSz7wGbrtaiuIdiU= 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 5.15 55/80] be2net: fix potential memory leak in be_xmit() Date: Mon, 28 Oct 2024 07:25:35 +0100 Message-ID: <20241028062254.146802673@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241028062252.611837461@linuxfoundation.org> References: <20241028062252.611837461@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-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 b91029db1f211..13d5fe324d6c7 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -1382,10 +1382,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. @@ -1394,7 +1392,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); } @@ -1408,6 +1406,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