Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3097833pxj; Mon, 17 May 2021 17:43:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLHApDpB1tqgA907xghutN9JYjEyEY8UQ9tZnDbcVSGAWdhakKETXg/OziBptbWBQBrHa0 X-Received: by 2002:a92:8e03:: with SMTP id c3mr2027400ild.167.1621298619583; Mon, 17 May 2021 17:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621298619; cv=none; d=google.com; s=arc-20160816; b=k4/im4kddfUstAzZLDTq5tWpBesIqw31Uq+YEW5JfGMF6EI3scyIXNEO5tkuZfOiy5 3wooYBq8QHL7IPHI6t/ZFbrAQSbMxrX14qQBvkmx/9/kgdB7zP2iII4YA5PIpxHVVadq rcMbIoh6Pt6K5xNbo+jGjE9B9+qvlMyHVC4l/f/4riUntSpdERgJKiQXkwtfcgTzBkl7 S+hXECWiGGdsymKDKPyDYUY8omiYcB73hj7sNtrVopJoFUEvznHYyByKWlJA6bbjSkOh ztFjTUhfDpmG6S6t8rT2JmgpXeYG2ZZvO9/i6BMPppHmqhJBlLPN2hSnVW2HyMBXzrfo napg== 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=87PcRP3dErD61sv5E3+YtB8Tk5GogFRR1H8dRoir3AQ=; b=eg5AcgJq83PygdAdYIJAU0ldV7ZtzxuAHtjEGWgZ/OqZFJBY8NWutMhorRa31YbQSr tEUmWglMImH3oMKFwiAX9L6Jv9otLzbh9x8zcfMtweAwi/caJ9XTwi41+d3Z+wUW53vS mc1UpLumkQzWqDo9wUG7g9+drwk9UqypYUzsLKsIy9XywMqt4IlkvxxMw8Jp7fRU/fT9 c4TmjeozUoB0Irt9yjAA04yA+DnJgjKfLL8g/QNgHEzNhM1Da3Kr9fqgqpylKBlrviwv bAo/gAVGGtgc4vao2Q4TzHPneGiamGLZ4rf1hl5Ak3YBHT4FnXv39yEkEWHSuELuxuId nE3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aPSAFdmo; 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 p18si10534904jam.69.2021.05.17.17.43.27; Mon, 17 May 2021 17:43:39 -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=aPSAFdmo; 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 S239770AbhEQO3O (ORCPT + 99 others); Mon, 17 May 2021 10:29:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:53812 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239549AbhEQOYX (ORCPT ); Mon, 17 May 2021 10:24:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 806B6613D8; Mon, 17 May 2021 14:12:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260774; bh=78lOjUkP4NZDr4zyoU7dXRmggRszU0d7vbXK+8DvjTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aPSAFdmo520nabiAnk92IXZAfO+wOq3+2WQzCTAqraKHsf0PBRmQ7f5zIl1oEbF5b 0qche3/cVC04GsDTrX8n9XxqJHs+7w01b2CQYMPGCjNGOUhXev4KFJIqNQyyZoRitI +Iv/ijiVisQ0dGQYWuIvppprMJLXzmjIjipG28ic= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Torin Cooper-Bennun , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 5.12 233/363] can: m_can: m_can_tx_work_queue(): fix tx_skb race condition Date: Mon, 17 May 2021 16:01:39 +0200 Message-Id: <20210517140310.456885137@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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: Marc Kleine-Budde [ Upstream commit e04b2cfe61072c7966e1a5fb73dd1feb30c206ed ] The m_can_start_xmit() function checks if the cdev->tx_skb is NULL and returns with NETDEV_TX_BUSY in case tx_sbk is not NULL. There is a race condition in the m_can_tx_work_queue(), where first the skb is send to the driver and then the case tx_sbk is set to NULL. A TX complete IRQ might come in between and wake the queue, which results in tx_skb not being cleared yet. Fixes: f524f829b75a ("can: m_can: Create a m_can platform framework") Tested-by: Torin Cooper-Bennun Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin --- drivers/net/can/m_can/m_can.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 0c8d36bc668c..f71127229caf 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1455,6 +1455,8 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev) int i; int putidx; + cdev->tx_skb = NULL; + /* Generate ID field for TX buffer Element */ /* Common to all supported M_CAN versions */ if (cf->can_id & CAN_EFF_FLAG) { @@ -1571,7 +1573,6 @@ static void m_can_tx_work_queue(struct work_struct *ws) tx_work); m_can_tx_handler(cdev); - cdev->tx_skb = NULL; } static netdev_tx_t m_can_start_xmit(struct sk_buff *skb, -- 2.30.2