Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9986617ybi; Wed, 24 Jul 2019 13:35:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqyTIDP7viWNiaqOd+2Xep6gwvxR5gmY/TOtKfv4lrBf7WrwD1BH/0D2DZBdX8Cdl0y57yvs X-Received: by 2002:a17:902:27e6:: with SMTP id i35mr87211644plg.190.1564000549922; Wed, 24 Jul 2019 13:35:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564000549; cv=none; d=google.com; s=arc-20160816; b=E0yYwsIM4JZuvQ7gyxDJzlsVgXkmq3mb85sbN1c3DPUVz2UO4imzqGcrxlCArHobm/ aKcXE3hnjIAGOA6AhMqD0JKd4IkxU6dAYKZzhssQFR6kDFFIvZvhLiU32sd6fwU1951+ xYeqA9eeklzFobRjhBa0AJqtf4vG/1nwlXSJGuPVPozCk9ht5d+BUZkKO+4zkef5l6W0 zF6iD3y2hphds5nfZzjeQgqlW+90GBlpaWDUazTQXz+710cSm7gEmjXCngJkwi7BEE2k 2EOTb5jFZCOBOBgbG7HFV7jlp0CGfUn/WrDXjsokjrQ+08TQ4ov587kskAbhnzWYqUJA SLYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4Pg+ggSamj5JatG8sLz99JgvUOMoVuMZDlgvDJ5tti0=; b=mIFUNfUw5gp351g6hSvKRJsvKXbrP+JtR5HpiVVENpIdycjyUirYun22tp+mHIJ3MG eJsRMKdJ5XKIwvkg4MDJEqSeXPbm5cqPrqX62VJbkUh0YDQZTftl2k5WzPrfcQ3T3bFC NduY4JhLJ+Rtuzii+eT+dm9CBddOYOSZhdwoPsLlTxMg+hvZYx52hla2d3+6C496luxo htfkSVTiT4QrgpfA4oPJnlp1gJik92eu0HkD6+0fnJNcuvjuMC9cjaG53uWE4N7hIziR dYNWX20vLuAc3WskMpxSXNY/xzH1mjzuxGRg7iUmtjirHs8iNqavvUdLCOWfax1eMHAM T3kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xKKjID04; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b24si15910459pfi.180.2019.07.24.13.35.35; Wed, 24 Jul 2019 13:35:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xKKjID04; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729147AbfGXUdx (ORCPT + 99 others); Wed, 24 Jul 2019 16:33:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:45474 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728088AbfGXT1i (ORCPT ); Wed, 24 Jul 2019 15:27:38 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F126E229F3; Wed, 24 Jul 2019 19:27:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996457; bh=Ic/A8kNZeS40Gc0OvdGwgwwBx7unIcFf4oygHMb8BtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xKKjID04RdVsntC3MYGfAwTUwfDjJjX5nfKtdQU4KZKjfSFc4vdPDoxAcHjPGd3Z6 FH+Vqv8KxXByrOs3RkMxVci27EKSntrNz8knvnCBGTG1l04B7aaNcFEi3ZZODCPKRw 1Fkq8xZATG4lhnJFppSLRXlxPy+ZG7dOasDCUIsY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yunsheng Lin , Peng Li , Huazhong Tan , "David S. Miller" , Sasha Levin Subject: [PATCH 5.2 103/413] net: hns3: fix for skb leak when doing selftest Date: Wed, 24 Jul 2019 21:16:34 +0200 Message-Id: <20190724191742.593413313@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 8f9eed1a8791b83eb1c54c261d68424717e4111e ] If hns3_nic_net_xmit does not return NETDEV_TX_BUSY when doing a loopback selftest, the skb is not freed in hns3_clean_tx_ring or hns3_nic_net_xmit, which causes skb not freed problem. This patch fixes it by freeing skb when hns3_nic_net_xmit does not return NETDEV_TX_OK. Fixes: c39c4d98dc65 ("net: hns3: Add mac loopback selftest support in hns3 driver") Signed-off-by: Yunsheng Lin Signed-off-by: Peng Li Signed-off-by: Huazhong Tan Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index d1588ea6132c..24fce343e7fc 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -243,11 +243,13 @@ static int hns3_lp_run_test(struct net_device *ndev, enum hnae3_loop mode) skb_get(skb); tx_ret = hns3_nic_net_xmit(skb, ndev); - if (tx_ret == NETDEV_TX_OK) + if (tx_ret == NETDEV_TX_OK) { good_cnt++; - else + } else { + kfree_skb(skb); netdev_err(ndev, "hns3_lb_run_test xmit failed: %d\n", tx_ret); + } } if (good_cnt != HNS3_NIC_LB_TEST_PKT_NUM) { ret_val = HNS3_NIC_LB_TEST_TX_CNT_ERR; -- 2.20.1