Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2352759pxb; Mon, 20 Sep 2021 19:50:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqG7/L08EkJwID0FptKv2vxGeVQnKORcdTOs8rdH9jNLmPxI/VBOA6fmDQk5oNhZSyEeyT X-Received: by 2002:a6b:5106:: with SMTP id f6mr12657137iob.116.1632192609936; Mon, 20 Sep 2021 19:50:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632192609; cv=none; d=google.com; s=arc-20160816; b=b6WBb8QqUQ5YgXHJrB/IgF9rz+Ap9ZzzbeWOnJcgG130fBWLqxJvpV5ovr6oAxZJgS +q8k1VByW/TCca3puLa5/bw+AAVtFWhRAMG4n/aMXOCguX6w1ehDjGyd2L6rEb6tBh2P zH4JvE1iHzKeY+usxGQYj/9RFX4bff2g+ABvwKQZOGFKF1b+8YUC17PlnAAmQuDbRjDX e3tVW39ef9LIRFl9YOyZW1M6ec3KkGDBH2Gd4Fwi0fqx47NBpgpoeK+8gAlOAr6q6oAR hgy/VBJ6JI/jLL9nmn36Zp9q2wFEOmprgS9/WDn80ztr+SHfxbbyjB8mveJXkA5Ccl2u jQSg== 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=nZuslq+1Kug4p9A59TWORhizG8PH/4V2zaHjg9llvUU=; b=CHGIFPDsNV3CgLA06Gu3ZivBHBNg66wSv2z35sEm06XSzu8nMBLqIO3Y6V8fo8D+5Q 6aA+Z5qT2sgJdyCxxe+qbJZnsnDwovn+JXhCXTkW0SkZtWkQ+ItliCKXju//6P4Ic0OC Al2sTvv+h7Z8k5qJYmyX+XBZxJkLqmmTcQSyHFdc1rZoXgVwkjYxr/fNbGZAMz8D8fDN MTUqWn1Uz4MHHO+4alz7WpviNlOsU/IpMhrezgR9FZvcfyuO28t0Y5YGTiewsjJc0bzF hTvV8HSIC42/j9vST6+IBjyp7JYFiGhbtVvc4RPw5ip6H2xlG1o/BXuO7tx3HPFtNdM/ Ekfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lSqnsQUH; 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 r17si17729472iov.104.2021.09.20.19.49.58; Mon, 20 Sep 2021 19:50:09 -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=lSqnsQUH; 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 S1382251AbhITSkP (ORCPT + 99 others); Mon, 20 Sep 2021 14:40:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:53122 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380886AbhITSfB (ORCPT ); Mon, 20 Sep 2021 14:35:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D95A161AAA; Mon, 20 Sep 2021 17:28:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158931; bh=8TqArL+z2lYrdkY/JU0A2XqwBC+e8fr5C/fpXsiGA+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lSqnsQUHI7H8lKXLINNi6E1S4YSVAksaeL/6pb9JTtxMX3+q3CSAabafci+dHCs0f mOhqSqhnEM07XagA6aAZlHOSQCySTLc/LEPyIf1wJsmpjKCsN1qQmtreirLBqD+w68 q4C9N16hNIhPGs8csH3O39XnP8/cEgLRHtWqQIVA= 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.10 121/122] net: renesas: sh_eth: Fix freeing wrong tx descriptor Date: Mon, 20 Sep 2021 18:44:53 +0200 Message-Id: <20210920163919.779174316@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163915.757887582@linuxfoundation.org> References: <20210920163915.757887582@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 5cab2d3c0023..8927d5997745 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