Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp217981pxj; Thu, 20 May 2021 07:55:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvwyYaNMMydUtwd/gfRGdvJwCntepFfBQ64XbUhMRTrJwaKFdLAosQws+dv0k77/4ugBG0 X-Received: by 2002:a50:d589:: with SMTP id v9mr5597584edi.126.1621522534098; Thu, 20 May 2021 07:55:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621522534; cv=none; d=google.com; s=arc-20160816; b=XNJN4TQRGKEcpEEA0PL8P2A6/3nvP2KFETYNIlfQSOt9pEz2usFAtSma6Jf0UzZ17g zZZiRwNwWa3YognQXXvqpxGx5D2pC4iiLBVlfjC5P5g3Q9zPjdTZ/P7eWsWxD3I6U5kV 5PHXy2StpmcFN35+WRNKI1gsejJXAiW2kDVtWL1UjXCgGSqP45Rm0yJcJJLR8vM+VbfN Woz54i6n1+PRNRgoBqz3e86kFKEBXJOxiIIaNaWlP0neVx3wszeWbb5puJ2eNEdch2nv OLh0jkxQ8YNR+VcFQYMZFzvpOeGQ849Xf+W2jaBH/QGuwvWGLMVbyl9xiuRn8jU3akOp frGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=eUf6OTRSpEXgy3IDGjtva6GsILME2d4kfdMHVHdxN5I=; b=ET6tBvUKLRuekbQcP86usxnn3OSG6pKpebv/cQmkmoyb6vFaj+kEsFeRe84By1fCy5 0L3hNNohe7etXhF2CtDMqoTiX6UYBWZGxgi3AfzzgNavdxXBy0f7vBQCHCHXhUpId9nE iIVaj7fEYHWF794ys47+cnXUmkM9IDMFDsfrJ8KHG2Jl7rxrUBjdGRuJipBPeyutr1Wn ikndzBJSaN2nUm/OXpUuNK8ulxC6cTsQP0nDGpG7oF5t1P8RE62ixwOsvfshrUYQsuHh QuZ5a3D3V1BMpnntvTgyfSWr4gakQpnzwkRQvCHaVsHDbXxyPlwewSYKggllvkH+m+bv 2A5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vTjv4x8G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e7si2525363ejj.140.2021.05.20.07.55.10; Thu, 20 May 2021 07:55:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vTjv4x8G; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232156AbhETJ2V (ORCPT + 99 others); Thu, 20 May 2021 05:28:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:52886 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231908AbhETJ1V (ORCPT ); Thu, 20 May 2021 05:27:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 76E946124C; Thu, 20 May 2021 09:25:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621502759; bh=5EPzffGvsdOFYPX4tm9bVja+aoL9dILhXUE4Y/w9V5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vTjv4x8Gp25GyL3zSE2xa/e6p7obDWhdy40XQG8Y/Xh4pMhMlJLWpUPmWDzL2g77U 0ZBRBODan1ofvLC4crMgclSSiwKE8K19FLbENYum+bN6EtESqQ4IhRvsHz1oic8cma zyXkIpCBFy0QWmlnhfdorzUsPMt6UcwladIKnd4Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?=C3=8D=C3=B1igo=20Huguet?= , "David S. Miller" , Sasha Levin Subject: [PATCH 5.12 37/45] net:CXGB4: fix leak if sk_buff is not used Date: Thu, 20 May 2021 11:22:25 +0200 Message-Id: <20210520092054.726023705@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092053.516042993@linuxfoundation.org> References: <20210520092053.516042993@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Íñigo Huguet [ Upstream commit 52bfcdd87e83d9e69d22da5f26b1512ffc81deed ] An sk_buff is allocated to send a flow control message, but it's not sent in all cases: in case the state is not appropiate to send it or if it can't be enqueued. In the first of these 2 cases, the sk_buff was discarded but not freed, producing a memory leak. Signed-off-by: Íñigo Huguet Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/chelsio/cxgb4/sge.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c index 256fae15e032..1e5f2edb70cf 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c @@ -2563,12 +2563,12 @@ int cxgb4_ethofld_send_flowc(struct net_device *dev, u32 eotid, u32 tc) spin_lock_bh(&eosw_txq->lock); if (tc != FW_SCHED_CLS_NONE) { if (eosw_txq->state != CXGB4_EO_STATE_CLOSED) - goto out_unlock; + goto out_free_skb; next_state = CXGB4_EO_STATE_FLOWC_OPEN_SEND; } else { if (eosw_txq->state != CXGB4_EO_STATE_ACTIVE) - goto out_unlock; + goto out_free_skb; next_state = CXGB4_EO_STATE_FLOWC_CLOSE_SEND; } @@ -2604,17 +2604,19 @@ int cxgb4_ethofld_send_flowc(struct net_device *dev, u32 eotid, u32 tc) eosw_txq_flush_pending_skbs(eosw_txq); ret = eosw_txq_enqueue(eosw_txq, skb); - if (ret) { - dev_consume_skb_any(skb); - goto out_unlock; - } + if (ret) + goto out_free_skb; eosw_txq->state = next_state; eosw_txq->flowc_idx = eosw_txq->pidx; eosw_txq_advance(eosw_txq, 1); ethofld_xmit(dev, eosw_txq); -out_unlock: + spin_unlock_bh(&eosw_txq->lock); + return 0; + +out_free_skb: + dev_consume_skb_any(skb); spin_unlock_bh(&eosw_txq->lock); return ret; } -- 2.30.2