Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3966986pxb; Tue, 2 Mar 2021 03:20:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJxQ3x+ibSdbIZKaQs9BVcKNP1eS9SQCLvVGmTsMVZTSHD3stwov/KfpiFMMDbm8tCbdgtxq X-Received: by 2002:aa7:c3cd:: with SMTP id l13mr14536808edr.52.1614684038063; Tue, 02 Mar 2021 03:20:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614684038; cv=none; d=google.com; s=arc-20160816; b=UEpUzN7VG5lFzqoXkF1SOewpREwdjPxk8i5Y9PQXkEUqzLAtaYT2yD+MLsqLCXaBHh aAP0EPi42Jkxi0+6tMU+9DqAn5QweeDWjY9eTz+8vn78U+MXLxjsP9QGPWOlcJkeuRU9 D5cVz6Wd+Dscg1pRv8qQZJUP9peHhHEKVO6pyXrVYj7gWWe/6sEYUpmPjxA3A+RTAANd dYF3Go4BOPK7OAvvwK4cDu30OiRTF9p2DHejXWde3uBVxhviPa60MN7i8WOoKha5GPVE lbZygTWULMCr8BMHBG2i1+GBK0yhZ8A8ucqMyFA2/dbn9kCPVJn9ld7TShPYoU0x9JK1 ZOrA== 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=Ato804X+J9hTk/jYLv2EdyY34yq2dwWnYPZL/JoRoVY=; b=dj7Ei25Se72dOuuKnDYRgoosd0svxK90pdjolBtxIssTAxgHr5yg/SsKwtWIISeann UQNSStX9/DnlgPmawCO2DFLgbYHGxQ3RX0tNRsxEyTmrMD44jqEXuUWlGvD72K6+ou8/ vNlXxOKSJFWlnkYFFEgg0PmqM1udh+0pWdzZ8K3ZO5QmRLrjs55ijIysUkeLyOi082aU ntoRkdIC27HcaVEX3ShVK9BK06sLQzPVgEeZssJSeNQA3ww4YwFbEVdeg+7b0Su+uTAy xOau3YF/IQIAWGedjwyo0bCfDicUi9xW+BZxLew10qCBYAMv9rqMy++a3CHZ1ZGh+q8Y tt7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="FuWqU+/i"; 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 o5si13026977ejj.164.2021.03.02.03.20.14; Tue, 02 Mar 2021 03:20:38 -0800 (PST) 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="FuWqU+/i"; 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 S1380592AbhCBByD (ORCPT + 99 others); Mon, 1 Mar 2021 20:54:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:48614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241889AbhCAT3k (ORCPT ); Mon, 1 Mar 2021 14:29:40 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 08F6E651FB; Mon, 1 Mar 2021 17:20:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614619202; bh=alnWrZccUvBfsoVvvdznE4kZl6VBD8rXoxUhfQ2/FF8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FuWqU+/i7Au7LEeh1ICEoB3+kpvFcgZx1vmqcBDOLcW5X6mozxnB9pi8tqvztrKUO o6vv2my9w9+0GXKXpLgUg+WtKZdNmysH41UpeMkDcgm6u06OuUowUVz3puUx2acHZI /9N6CVlK9vny8J0JWwjfpuOb4v0i/ZooIOEWgME8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Phil Elwell , Nicolas Saenz Julienne , Mark Brown , Sasha Levin Subject: [PATCH 5.10 370/663] spi: Skip zero-length transfers in spi_transfer_one_message() Date: Mon, 1 Mar 2021 17:10:18 +0100 Message-Id: <20210301161200.154477680@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161141.760350206@linuxfoundation.org> References: <20210301161141.760350206@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: Nicolas Saenz Julienne [ Upstream commit b306320322c9cfaa465bc2c7367acf6072b1ac0e ] With the introduction of 26751de25d25 ("spi: bcm2835: Micro-optimise FIFO loops") it has become apparent that some users might initiate zero-length SPI transfers. A fact the micro-optimization omitted, and which turned out to cause crashes[1]. Instead of changing the micro-optimization itself, use a bigger hammer and skip zero-length transfers altogether for drivers using the default transfer_one_message() implementation. Reported-by: Phil Elwell Fixes: 26751de25d25 ("spi: bcm2835: Micro-optimise FIFO loops") Signed-off-by: Nicolas Saenz Julienne [1] https://github.com/raspberrypi/linux/issues/4100 Link: https://lore.kernel.org/r/20210211180820.25757-1-nsaenzjulienne@suse.de Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 7694e1ae5b0b2..4257a2d368f71 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1259,7 +1259,7 @@ static int spi_transfer_one_message(struct spi_controller *ctlr, ptp_read_system_prets(xfer->ptp_sts); } - if (xfer->tx_buf || xfer->rx_buf) { + if ((xfer->tx_buf || xfer->rx_buf) && xfer->len) { reinit_completion(&ctlr->xfer_completion); fallback_pio: -- 2.27.0