Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp505390pxj; Tue, 18 May 2021 08:11:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzoNZ8duZVrDdHlkfHHdj0a5reGVOiGEjQhmnd1FFTNrtnNXPqrpjIyi/I8ea6GQihHStaO X-Received: by 2002:a05:6402:1256:: with SMTP id l22mr7706466edw.207.1621350704356; Tue, 18 May 2021 08:11:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621350704; cv=none; d=google.com; s=arc-20160816; b=J6o4ZqvCzr7rlOzVZP94ERDB6x0fNrjdtMXQq4UI/vkpAJaH8Q1wAhg0w4eXODEola MVfW84TSr1+blo8vUwwNsSm73oLroahbqONPX4a66AJAwbwJCk+NbJA7yjz/lTejKtOr s0jBaFuqVNq1xV2pTTrHBEgKtYCE+1jHlel3AoAyWKaz10vbaSsDa3EQPgEs+/tUJd0C xefQF5vheE14kxbR0iHNNvhu8Rgcn8VRbJFsMgGfQuLv4CApeZpzsqYTz3B7G/hhk6uo UWjtrBFlHOfgep4myxMqb74ahQumREmyQov3oxVQY1BwCCTaGY8bKnYl6zwK5DDVfD+e G2rg== 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=6BJK+c66MU8CJXt1RgY/4LETf57CZHLd5qSd/1WkE6A=; b=qmYAAi7Q/HlBRdnkhItxr3JtIZ1ai4jjCUcxj8ce6PmFkGHlKzWPKUinpWb2AWXIM9 ZPmwevb2Kss/kOt4twK3Zqg0ohMKyHN461ogc8IJ30GMlMh/sdM1vnlujs+NMVype59u 9X93UZiPPrYejbtfBeA2QGM442IsQv2STXpbWhmxk8RBcIKTsGkTtYB7VLOCOY16Icnf mQh6OBc9UmCuw7FPRheD3ONhkf04Ni2gtXaGqgkVZITwYZc+ODlMfZmJypvy/1Xm5D2d ogP5gCflmKm22lHY4x1vnXyHDMOhG2r06+mWf5uJEyulGnhoQH0d/SUbGCVLfoaNoKj/ qAEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bNhx4DUt; 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 c19si17451600ejj.494.2021.05.18.08.11.19; Tue, 18 May 2021 08:11:44 -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=bNhx4DUt; 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 S1344792AbhEQPya (ORCPT + 99 others); Mon, 17 May 2021 11:54:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:39558 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239208AbhEQPgQ (ORCPT ); Mon, 17 May 2021 11:36:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 34EFF61CF1; Mon, 17 May 2021 14:40:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262402; bh=WvSWoJDf73Rn/knX08lPxpMQ9NlWkFtyfL6n8gjN6aM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bNhx4DUtA+ZWfcIlMABstHEL+LficEV5ZjNRfCIwMKmNlqYhLbcDAROWV/5KR+sEq R5lYPobwvImaPYTuwsedwPp5TjC/5JKZAT3GE1nKv+Lqom6GX7k9AAG6xAVsRCJh3Q qsjFEMMKGN53gzroJ5Ia9tXTCUkhcbioqY5ffOAA= 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.10 180/289] can: m_can: m_can_tx_work_queue(): fix tx_skb race condition Date: Mon, 17 May 2021 16:01:45 +0200 Message-Id: <20210517140311.173749440@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@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 6f0bf5db885c..62bcef4bb95f 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -1466,6 +1466,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) { @@ -1582,7 +1584,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