Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1529003imu; Wed, 28 Nov 2018 10:51:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/V95gRjaBG0wN3t08feQcc4POZo5ewnounZD/qmIsRLHfn4twPdKWvM3iwWxqlOQ8W3lDj7 X-Received: by 2002:a62:2a4b:: with SMTP id q72mr22661576pfq.61.1543431113365; Wed, 28 Nov 2018 10:51:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543431113; cv=none; d=google.com; s=arc-20160816; b=i7f8ITxxpYWuBtuW46etopo5zow2+Q2uOxx+iNU+JxmmEan1XHqNIgsTswbZ33OjHG ++dfavyQcmmMTLK2aCxHndZNT4+TLVOeGNiaEP8gDS2I94b8VRcp4FB5pXEh4f0lR7O2 GvEwj2YlXhVJnxhSf0bhOS7S0QkZQ/Bos3xwg2z5+sDrqj2EF2h4AtcoyD+mCgEcAAfC kaUZO3J9UMKhcm4QnuTjXUjq2RxbJ5B3BpYsv/H3YbQL9aWuvZPymUgeHeA4eU5pZwFR dwqRrQo+l1TZ9k+fMZlD5x/wdePIPvaT+TqT1EZR5VgxJPXpMuECBAeTI2eZkL1dJuF9 YxpA== 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 :references:in-reply-to:from:subject:cc:to:message-id:date; bh=Ti7x5fYVIgQYIM6ja3Mz7Mj9EFMTKU9wQ6F/LJRhNnM=; b=AQQScUkP2TL46Cts2WWkgpDMA2YoP9qJOHYYk0N5a+f2G+WCXn9ncO4wwCQiU6y0lZ qLlwQrxonqviG5kbatkyMz5jXCnEp9XgkxyoU9ZkH1s5v7HXfjYie5Nk913IA+dPJeQD 3EFgXaxZ3eyeY+1NyIX67S86iOlA+Vwt+XsHbr8rTCYzcQS6dJsumfvxwMaGrW21gnCo OxTWGc7PGWnk5urPIXbRT7oW5D3givwH6ls3v0LsyJgy8nV5TwrkEvhlyLjsE663VOB4 K1S5G2kYj5NGI2B+QBYDRQ4ZKogTyQKypJXNZtmQA65YIG0w9T43/AtMeCJDBsnVD0Eh L+qg== ARC-Authentication-Results: i=1; mx.google.com; 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 i66si10411262pfb.91.2018.11.28.10.51.37; Wed, 28 Nov 2018 10:51:53 -0800 (PST) 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; 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 S1728834AbeK2FwJ (ORCPT + 99 others); Thu, 29 Nov 2018 00:52:09 -0500 Received: from shards.monkeyblade.net ([23.128.96.9]:36200 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbeK2FwJ (ORCPT ); Thu, 29 Nov 2018 00:52:09 -0500 Received: from localhost (unknown [IPv6:2601:601:9f80:35cd::bf5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 8557314E0761B; Wed, 28 Nov 2018 10:49:32 -0800 (PST) Date: Wed, 28 Nov 2018 10:49:31 -0800 (PST) Message-Id: <20181128.104931.1898736297454841540.davem@davemloft.net> To: bianpan2016@163.com Cc: thomas.lendacky@amd.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] amd-xgbe: set skb to NULL after freeing it From: David Miller In-Reply-To: <1543392585-17962-1-git-send-email-bianpan2016@163.com> References: <1543392585-17962-1-git-send-email-bianpan2016@163.com> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Wed, 28 Nov 2018 10:49:32 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pan Bian Date: Wed, 28 Nov 2018 16:09:45 +0800 > @@ -2754,6 +2754,7 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget) > netif_err(pdata, rx_err, netdev, > "error in received packet\n"); > dev_kfree_skb(skb); > + skb = NULL; > goto next_packet; > } > > @@ -2806,6 +2807,7 @@ static int xgbe_rx_poll(struct xgbe_channel *channel, int budget) > netif_err(pdata, rx_err, netdev, > "packet length exceeds configured MTU\n"); > dev_kfree_skb(skb); > + skb = NULL; > goto next_packet; > } > > -- > 2.7.4 If either of these two cases are executed, it means that it must be the case that: !last || context_next is FALSE, therefore the conditional in the tail code of this function: /* Check if we need to save state before leaving */ if (received && (!last || context_next)) { rdata = XGBE_GET_DESC_DATA(ring, ring->cur); rdata->state_saved = 1; rdata->state.skb = skb; rdata->state.len = len; rdata->state.error = error; } will not trigger, and therefore we will not record the free'd SKB. And if we iterate the loop again, it is guaranteed that 'skb' will be set to a new packet or NULL. So there is no problem here.