Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2354294pxb; Mon, 20 Sep 2021 19:53:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7apQHOTjnxp3LVTrlz7+m4noTK04QwMLO71ZxVFR+f3TTq8frmvrTAggLuv66vE+InGyl X-Received: by 2002:a17:906:d045:: with SMTP id bo5mr32236803ejb.461.1632192814456; Mon, 20 Sep 2021 19:53:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192814; cv=none; d=google.com; s=arc-20160816; b=k/zDUiN8ZTVpTJ8Ul0xyXhHT30jJgS+Umuk/srJ8FxZcqHAoOGJjxjoxNQwrb2R+pC Sm3GP/S1lj9bvDB4nwNDg5IshRVIVbU3GOpE69dgcd+qPbsuTm1kwG2/ZttAPXtA91Ie FBJxKOvT92o6NewyRvy1UMkZ80QGMKZrTf7Wzr039dEN8lMNlWcDYSHl8U8PxGsxvDeJ DnWdL57k1LZfUsOOK3eN1uvNSZfLZF47K2JszX5HcYu649cBqqhidS8aqy9nNmNHTPmv MuFZn9PxX4UuH5aIK6btH+YPVOwIeBZ3aMbVDrTrytbYPfRMoQa5wXnO2AQLMrx4VQBh ONnw== 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=M3ZEmfaTx1SV+TwrzGylKC4T+9CD9yyF886eScipqa8=; b=LAQeDdRNEijvT/kQD+i1dVTVZY85SbO34+UBypHraeTBLsIKARwnikqmWcNN8Jjljg DJzh4S/2NAwY1gegY3RjMdYuGSvZ7yB7rKf2+Y0FPxFa9xuyJGjDiOPbnZ1+XYLsadZ5 fA2HC5He1cdFb1fczi8IKNoVhkDhGlR4LQrOx638HttU0AqVWdMPa0TDF4oegiaKrrig KAIVQcpIqO19mxVop0QatT8cQawIs9ikzP3tMeNa5VH07RRe8sR9h4qYVvyk1daAIB3H 68WGKtuAINBtMNMyW1BpuJaEECngfbwXyFlIIYvaPqCz2jQva1lte5VCoyNMquXzi0cX BzDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KspgJuxk; 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 5si18790832ejm.407.2021.09.20.19.53.11; Mon, 20 Sep 2021 19:53: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=KspgJuxk; 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 S1384656AbhITS52 (ORCPT + 99 others); Mon, 20 Sep 2021 14:57:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:37126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385800AbhITSw2 (ORCPT ); Mon, 20 Sep 2021 14:52:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6606663395; Mon, 20 Sep 2021 17:35:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632159315; bh=dTZ0jGQNK7l0rIGdBei6joEsPHyNhNMqX4OAAJcD33w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KspgJuxkbFQiszHTkuKaov8Acht3lx/pXjXC9CDGjrl+sTQE6+zcJ1XaxzIst8KGS 3y9Y+M7xWOtrQmPkjUCIRgQyflAcpxc4Rgsto4u1v8O2KrmAf126H32lwUxqQOaiwz boAh6iWlGD2HirhK90kyuMXDTHpOF8k9kTDqUmdI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yoshihiro Shimoda , "David S. Miller" , Sasha Levin Subject: [PATCH 5.14 168/168] net: renesas: sh_eth: Fix freeing wrong tx descriptor Date: Mon, 20 Sep 2021 18:45:06 +0200 Message-Id: <20210920163927.199009618@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163921.633181900@linuxfoundation.org> References: <20210920163921.633181900@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: Yoshihiro Shimoda [ Upstream commit 0341d5e3d1ee2a36dd5a49b5bef2ce4ad1cfa6b4 ] The cur_tx counter must be incremented after TACT bit of txdesc->status was set. However, a CPU is possible to reorder instructions and/or memory accesses between cur_tx and txdesc->status. And then, if TX interrupt happened at such a timing, the sh_eth_tx_free() may free the descriptor wrongly. So, add wmb() before cur_tx++. Otherwise NETDEV WATCHDOG timeout is possible to happen. Fixes: 86a74ff21a7a ("net: sh_eth: add support for Renesas SuperH Ethernet") Signed-off-by: Yoshihiro Shimoda Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/renesas/sh_eth.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 840478692a37..dfd439eadd49 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -2533,6 +2533,7 @@ static netdev_tx_t sh_eth_start_xmit(struct sk_buff *skb, else txdesc->status |= cpu_to_le32(TD_TACT); + wmb(); /* cur_tx must be incremented after TACT bit was set */ mdp->cur_tx++; if (!(sh_eth_read(ndev, EDTRR) & mdp->cd->edtrr_trns)) -- 2.30.2