From nobody Sun Jun 14 07:35:29 2026 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5E473BED6E for ; Fri, 1 May 2026 14:00:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777644004; cv=none; b=pu64ZnwRTXRUKY5fzW9YgNC9or02sSq3149O2QIHuHpa9KdNzms28AqGktp6jLW/iFrDr/JGV+4qj8Q12ug9m+BdXPSijkNmDAetlEniFBf7re247yV2Nx93pNn9ip6ddzIM7Gbb2qu+nrcjfjCY+AhxRu9kdmL1YSx+RN5YQX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777644004; c=relaxed/simple; bh=FPDrMq+XXIYVnA2vxX/dXx8+DI8MvzMK7n/I8l8+h0g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fnf4MlseDlyqom7ahgLJDdQ11hVbmoVuR1S0D6IyN4P/MymCzHvHjmTP7gJ6hsVIsad6pv0gneYMqXYGvQNS5wC8jZa5IBwa/0log7BDlwTWw7ykHkV7tsUTn71snj+QqHufLlVUeiTYahuljFrBQHHN79OkIS3qn2hKpV27Uys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NpEV4CgH; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NpEV4CgH" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-488a8ca4aadso22654425e9.3 for ; Fri, 01 May 2026 07:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777644001; x=1778248801; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wV29etHKmeXpNOvM6Yg7tazjewCc3IV5UL8KyxdRZok=; b=NpEV4CgH9bLaAomUyEEbnAYQcSvLD4yPF0q/pNbuSBNO41D636WTeVb2JlCiZpmcpi wmhhBUHEGZEuIrJ9c3tK2ONSs7zR6G6zW0JLfTf7LAco+itrdxzkdFPQgfs2GmEdWVA1 C4rEGSzhNTMJYrgVvu+3NPIUqYLwhLscS0qwlZp1oZtg8ZuTlQD+Ru50BISWEthUnn+l hOFyvysnsKXm6+4RV7PR9hwzFfxg/YbYqr6WAGTt5AKF7giw4R8pZn3JdCZU2hZYlGAX E89S6vaFV+vp6iQp/U5++60dSsLtVuHqHZA2y0LhEs1StjgFMLU8UZZE0LrQUo1NVV0I AQmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777644001; x=1778248801; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=wV29etHKmeXpNOvM6Yg7tazjewCc3IV5UL8KyxdRZok=; b=a99VB3ECuFl0K/GRCG20dthQQNYmZrpFrw83yCL0E03ovcVLq8N2VxReURFKwzuD94 nbUoSfL7Jc3pqdXi2tTwadJ6wTo8cbzlQZvmB93IkD4XPJn4QDqjFrBT97jRTf0qecEm sAOIL9GXmSn8gHIWE+2hz26l9fMSIek51V/Aygw78k3qcrbx4jkUwi2ZU3Sq17r6y/gS 1WPMo7uRa34rdZ0i8VRITLdU4CZYGPIVvStrutDGX5ZPli19eFs4n1BmcmQ/2hDLS3Hy qoXjzHIscxnq/KIf9WU14lrqasr4d7cTytxXQEWqabSA5gbqF5NCYnfVfIkp5lleYDjr 3AsQ== X-Forwarded-Encrypted: i=1; AFNElJ8v073z4UNLu+IThei2cX5OXA/Csq1wit6ApFe6ezt0Ztut6sWcVRvRm6zoevF91GKh8cPhcgz7yFDtX/Q=@vger.kernel.org X-Gm-Message-State: AOJu0YzT15eWKG9rIOB5sjgbt+79mjZe8hX067DwzPJi/bD0fs9ZziNs DXENgv1/G7fVmvBfSAmJTijIsV1v0KBZrrTp6avtmj9w/FmUVUkJ+BsD X-Gm-Gg: AeBDiesxQ4XVtPabdQg+2dpVxHxb3OaiqJdPWS/DPttWnXs9G4XVVCGl3ct9l0q7K4x vBaQil5+zPxOmeU2irBn2P5Maj9TCH7NNZZzcCPnQ8Ik48w1KG3r9u9Si8d4O8mj53uS644FVTj +YeimXiQ6UYguog2qVJDrb3jQ4+S8oFA8n2zJrtesA7Vo4/N4eH81aGxPX8u/g5fz3dRG4EPuch erHXVdHJYZOZ1FWAd7gLRKIZHqZb0fvRTu7tNtCLy1idaOsQN7TSUjGRM7LzNFVsrAt5id6qf9w 5VffLPbNNKnDH1yzPKKqUcvYXbqFQ6Jzz6bonqerOpDszX8FP2OH/dSgsklyrF6eiZldv7KNYuS Ty7Zv0P5vFRRZIKg5XvJ1kS/c5pDInIHfO41A8hhH1EaovYJqyn/AdJcrxxmd1Kefn+kX4ImBZI Zzi6HQrH/XHC/PP5dcDsU4wvTsfcuuPFWdzr2EpobmMo0r6m36mc2W9cmZ4lT7DejadYtbrFHvB xRT X-Received: by 2002:a05:600c:a401:b0:489:1c1f:35df with SMTP id 5b1f17b1804b1-48a84452161mr92478485e9.10.1777644001371; Fri, 01 May 2026 07:00:01 -0700 (PDT) Received: from localhost.localdomain (ns31537009.ip-141-94-163.eu. [141.94.163.193]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-44a98b768fdsm4823539f8f.33.2026.05.01.07.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2026 07:00:00 -0700 (PDT) From: John Madieu To: broonie@kernel.org, Frank.Li@nxp.com, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, carlos.song@nxp.com, linux-spi@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, John Madieu Subject: [PATCH 1/3] spi: imx: Fix precedence bug in spi_imx_dma_max_wml_find() Date: Fri, 1 May 2026 13:59:49 +0000 Message-Id: <20260501135951.2416527-2-john.madieu@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260501135951.2416527-1-john.madieu@gmail.com> References: <20260501135951.2416527-1-john.madieu@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The watermark search in spi_imx_dma_max_wml_find() reads: if (!dma_data->dma_len % (i * bytes_per_word)) break; The unary ! binds tighter than %, so this parses as: if ((!dma_data->dma_len) % (i * bytes_per_word)) break; !dma_data->dma_len is 0 or 1, and `0 % x =3D=3D 0` for any x; `1 % x` is 0 unless x =3D=3D 1. The condition is therefore false in every case except dma_len !=3D 0 with i * bytes_per_word =3D=3D 1, i.e. i =3D=3D 1 and bytes_per_word =3D=3D 1. The loop almost always falls through to its end, leaving i =3D=3D 0, which the post-loop fallback rewrites to 1: if (i =3D=3D 0) i =3D 1; So spi_imx->wml ends up at 1 for essentially every DMA transfer, defeating the entire purpose of the function. The DMA engine then requests service after every single FIFO word instead of using multi-word bursts, hurting throughput on every DMA-capable variant. Add the missing parentheses so the modulo is computed first, then negated: if (!(dma_data->dma_len % (i * bytes_per_word))) break; Fixes: faa8e404ad8e ("spi: imx: support dynamic burst length for ECSPI DMA = mode") Signed-off-by: John Madieu Reviewed-by: Frank Li --- drivers/spi/spi-imx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index e5c907c45b87..7ae8078c10ef 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -1836,7 +1836,7 @@ static void spi_imx_dma_max_wml_find(struct spi_imx_d= ata *spi_imx, unsigned int i; =20 for (i =3D spi_imx->devtype_data->fifo_size / 2; i > 0; i--) { - if (!dma_data->dma_len % (i * bytes_per_word)) + if (!(dma_data->dma_len % (i * bytes_per_word))) break; } /* Use 1 as wml in case no available burst length got */ --=20 2.25.1 From nobody Sun Jun 14 07:35:29 2026 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3133F3C13E2 for ; Fri, 1 May 2026 14:00:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777644006; cv=none; b=tts3l65Dskmu+IKhR+rPz9JAevUUsACS1/4zDcjlZ35ooKcIkn2dTCMUNeNDhdhud7zVhzRZLKVp08CrYlQ48Zf8jU1ffQbveUM9kEf/mRMK1ZRuBqKX01+yR7bQ2IvEYI4y17q3nImOsNZHtOOQXC1Ma229csXb7dOfoCXUbZ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777644006; c=relaxed/simple; bh=jJjc9mSsrPx/NmfZcqGL2yYaLbyjJmbr1/4K0E8A+5k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LVJjqGxRwycnUKAEUSwnBy/uA0yiRD0Hh92fzctPrZ5LPiUML/a9Mijg8H+lA/4A6xzBcqI15CQ+57a6lkQLd5tJjQ4p9ZRgBCKzKY9dp6G3usIXRqxbJFX9SLZNK4rR+VohNc1wBdbAaY+nVSe/H9bCCH1gIdznQY2c8+7PL7c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=La/EMFcm; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="La/EMFcm" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-44a5174670eso452136f8f.1 for ; Fri, 01 May 2026 07:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777644002; x=1778248802; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wgCd/8OCqeyYKCVUvRrf/jlOcP1suVHYVb2aR3GPrKU=; b=La/EMFcmOAN/SOrahPkXF3e1bgWrauLOYTjjPaNvo53yWotmYUpRhz2J1BHysHu9Zf wN5ueQo6wf3TZES+KAD/f9kNkX6eQJ68SOspnw+/+CFBErDvplCowp0RhCh2i4OlzjdM XRZyKHVrLZLVi+a2NKPpzn/v3B58sihIguGX6sJatJjS008UBWECEoxqa941fVObTlET vRZduJxbHIwDAfWWfMcAFnJW2kersJE7xwbtPEvSz4PIwycAb+3mEDBxpyxS6u05o6wf UjpUWWLXdRk/b6vwEKL3I7mrZc1MyDmXzfi8KCtJER+pXAhNfH6Hrs8CdHZ4Nf6WG4tB bHDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777644002; x=1778248802; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=wgCd/8OCqeyYKCVUvRrf/jlOcP1suVHYVb2aR3GPrKU=; b=bVFM/Lgt7BdgWXyHarI7L3UoAiS4LQdzh0b/czHeuFZEpGnAoflPucXtSWPgvvUcx1 sMO6rTB5afUKyNHy3tSAMRwv9bO+dHC9hQIyPaaBWCm36JG96QIpuaCcOFNaBjqawOlR og1Bn7BY2o6HGgFEVkz/hIG0+s7E23ksxrLqwESnRyEQ3fFTEkNSo9lNk/iGnzICwZjG ZOxwqjq9j53Laf/ANO3M25lNxs44072DLgbPePpPpVJgiOk4M6GI44XwGlFvshgNEhwj nvsMD8d1UKmD6jfYmQkwow3+yzK2ANe0+kyXqT6YylU1wJkQ6HbZN89Q0jtayNZolHvs TWhQ== X-Forwarded-Encrypted: i=1; AFNElJ8PZLibZM/UqBpJwprQjAbUOuaeWe+F9OqHr8ljlWFsce23T7Dd5J++q/WWoYjG8vojvNUnJfRYltncvn4=@vger.kernel.org X-Gm-Message-State: AOJu0YwPvo1wJb0Ds6Bp3M3BNofCUFaVKs1vNYSiE+pOHs2FBcQwlGQ5 0JITxt+EUEt0+meurCkAiEXSwf8aKMQnpuyhFJa9sZHG/m4dK+89AATn X-Gm-Gg: AeBDieuERcXSO39WF8gbRE/VMR1q3IW9YJQB36J/BN0I8a25WUSfsYMsxbo3Cw5sbDy TR9Id06gLkr4VHwUH1RHs59Hmul5cKD8mLnbtD0g+AAKJCELtoid9u0BBLP3aYY3zD1dB0+ShWI 9KqwYiS08cvqlid0bxIr+GHvGJwyzpoqgmTxU5TbDajAo52HvzQS6unmGexzDEbO4oMmhVeeFns PqlCYWffX1NpXWdLaiZX82Lh67vzfhfGE5i661Amh1gEvFO3PT0E/8AIyoHSD3WugYRAS5DTncn 5z47dIeY0oCG693mbT/8w4U/MxThXP8xmRluPAr85XkCcgYc1RHb8XhnyT4ZEAVzje22pZSS13c BwJ+MArFHGJiSkolA0jyeBMMlKbl8Ok1yVvYMgrgIPBipmzSaK8jq6eAdBALW9CjcUc/oxUBb7x bvP5JL/9pYCc3eagzsp2FBVKVe9PVD73t3vh3XMU9rcsVQX9OCgbfCQV+XkoqW5RnLD9aygXGE9 QeX X-Received: by 2002:a05:6000:2b01:b0:43f:e2b7:7160 with SMTP id ffacd0b85a97d-4493cf2d5e0mr7464637f8f.4.1777644002422; Fri, 01 May 2026 07:00:02 -0700 (PDT) Received: from localhost.localdomain (ns31537009.ip-141-94-163.eu. [141.94.163.193]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-44a98b768fdsm4823539f8f.33.2026.05.01.07.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2026 07:00:01 -0700 (PDT) From: John Madieu To: broonie@kernel.org, Frank.Li@nxp.com, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, carlos.song@nxp.com, linux-spi@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, John Madieu Subject: [PATCH 2/3] spi: imx: Fix UAF on package-1 prepare failure in spi_imx_dma_data_prepare() Date: Fri, 1 May 2026 13:59:50 +0000 Message-Id: <20260501135951.2416527-3-john.madieu@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260501135951.2416527-1-john.madieu@gmail.com> References: <20260501135951.2416527-1-john.madieu@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When transfer->len exceeds MX51_ECSPI_CTRL_MAX_BURST and is not a multiple of it, spi_imx_dma_data_prepare() splits the transfer into two DMA packages. If preparing the second package fails: ret =3D spi_imx_dma_tx_data_handle(spi_imx, &spi_imx->dma_data[1], transfer->tx_buf + spi_imx->dma_data[0].data_len, false); if (ret) { kfree(spi_imx->dma_data[0].dma_tx_buf); kfree(spi_imx->dma_data[0].dma_rx_buf); kfree(spi_imx->dma_data); } } return 0; the function frees the package-0 buffers and the dma_data array, then falls through to `return 0`, telling the caller the prepare succeeded. The caller then dereferences the freed dma_data array, producing a use-after-free. Return the error from the failure path so the caller takes its existing failure branch. Fixes: faa8e404ad8e ("spi: imx: support dynamic burst length for ECSPI DMA = mode") Signed-off-by: John Madieu Reviewed-by: Frank Li --- drivers/spi/spi-imx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 7ae8078c10ef..4e3dbd01d619 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -1709,6 +1709,7 @@ static int spi_imx_dma_data_prepare(struct spi_imx_da= ta *spi_imx, kfree(spi_imx->dma_data[0].dma_tx_buf); kfree(spi_imx->dma_data[0].dma_rx_buf); kfree(spi_imx->dma_data); + return ret; } } =20 --=20 2.25.1 From nobody Sun Jun 14 07:35:29 2026 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6F9DB3C0604 for ; Fri, 1 May 2026 14:00:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777644007; cv=none; b=LUX20AufHg4YJR2pwkv3rmh9oYLTY7IvEFhdt3qv/0dvGTUMI9J4k/7mb0UfHNUqz+DYesANIy1HfwEdP0WR9DioAvFVnbGwo/vFOwqFm/O7MwKwpK9a7mwgK8x30KJC5Mc/6vVkZE/xegry0+5nsyzALMd93IqhmFm4aObiNhM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777644007; c=relaxed/simple; bh=wr1OnFxz/Ai5i4NfAvoS0ChTxZI8nshMYVtsLOtw7bM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kJQfEYxQi3yyHf8rfxERyMjq4oXmw9E2bcTO1+utkIo9MXcGXriPm1Of9q6hh57aZ9GrhSy04EBzPu93FJlK+zxz0YZwWMa2LVP5wugAoBuJ0Zr9iQCyqfhPhcPB2O36K4mmzRh2q6KQPBB25IKypS3Dma0bQz8fbej0Nww0ueY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cNsw21jp; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cNsw21jp" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4890d945eb4so17615615e9.0 for ; Fri, 01 May 2026 07:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777644004; x=1778248804; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/yRGhlBCY/TW5XKeeufbyghz250gEgHu0HIRBXKkoYQ=; b=cNsw21jpSnOytV59SVtqkExEglKmvBTMvkjf3Lr6djzZHTAVQD7PA7JWMjZ1hYvSv5 sAXqMpleKYEgqhLkmEamXLT67iSD+quHviMNEg2UEseHgWkRcWRAH9HMPR3rSC5B8943 SgSwH/BnuRmAPKdWmex9T/9NEUWbPWlUk3BYgQugJdbE/lWmBuPCRb0dxjKtZCV3sk7J VEjlNubKf4C0+DDPvgkbnDMYcdOKxQrp+fKjaxQ6LnSfS1fb2hUJry9NGEypy8laZInF jQ83niuLHSTDPpObYCf2xlq15s3AFK58Te1PffIDO30VCpDqL/2NxldQ4Q3V+DF8iMkJ SsuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777644004; x=1778248804; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=/yRGhlBCY/TW5XKeeufbyghz250gEgHu0HIRBXKkoYQ=; b=rHwpa4L3rLRj9tF45HlgDuOSdyxTFkq7mKgvEvweHpiJHuNiZHvlD52JguYRUeEK9p 2dMmZebWVfqn4hLBr+ldgNzdMMeBuxLUxpCdRb2afLjUpBV20PNffz8kDafTaQx2WKIo TtVAbRwsGJo21iTLhIlXGWJExjl043z5ypKUYHUdsGQ2mod71XUwULbVfDmNrvBQF3p4 Fb6QiQOBxbs1hnPDtMBGNCuqGyC3kczaq4D1DI1dEGdT8M0WCfHuQfsSZYMecKrUtLzY h6W8UjPKOGbE+VBc2Y+/TKGJNwcbSLSOuw8xaFIuye8g7dPOnAxwVdLgDlXc5RK6dB2x TOJQ== X-Forwarded-Encrypted: i=1; AFNElJ8m7yIiJfnMuP7kEWPrlklYgWhtGI1sLgO2EQxUmdoVzC7Q6InASFDZTJ/p0iZzJ5bDwu1Z54evI9fEc0U=@vger.kernel.org X-Gm-Message-State: AOJu0YwiIVeRhTEFWZz57tfyo2UeAks5sZOkAYhAWt4Qp5LiAZaz0aUJ 7djZbQ8PiX6rfwm6vGazCszrWcWO7nsat4lLDjjhOWtwkDkismiD2Sx6 X-Gm-Gg: AeBDievxAxzxrjgyGeeLVqNNPhLrb+PzQ1sE1WF3E0etekRcEtRbEcZ5FFaXdhAmrtU PmyOb6/XG4kSxDWACl448/yiAdPMxR9miVsB3mr85pR2jgq3/jeS+nOqLVzwz220CdDbv5RWwDp 98eP3sHAQr3ZJEWO8h0YmbvAvzkLiGDeaeaoH6AGRd4uYR12UQE5mQufnOvTMFZak5/caiJKDy0 pvuym96/zzbdior+4ft9Wex2//H643CkRumjRJwPRe9aQVFfUyJwy7KSGsxyY27q/593AIbVmvK tvuRf2S8QSTOWyrEF4GFRzjcy8fjCjsXGwJCSu/6DoBxZCmisfJYcnaZplLnPOXLMVhhbv0eQ3U INPxtiSHnXPwJcC+K89LeOHolmwb3KMrUQAh5mpMydDhuxu8hRZt/2dGXJxI1W8PqjenjNDz1gi 1/iaf+aJWz8WR9Uco31siPwzo9V7+UoyL4zgUueizh30i6W2SUDuwwZfEW5A3WmX813sSpUnh72 S+3 X-Received: by 2002:a05:600c:34c6:b0:48a:761:5816 with SMTP id 5b1f17b1804b1-48a85e7c80amr105322175e9.8.1777644003492; Fri, 01 May 2026 07:00:03 -0700 (PDT) Received: from localhost.localdomain (ns31537009.ip-141-94-163.eu. [141.94.163.193]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-44a98b768fdsm4823539f8f.33.2026.05.01.07.00.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 May 2026 07:00:02 -0700 (PDT) From: John Madieu To: broonie@kernel.org, Frank.Li@nxp.com, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, carlos.song@nxp.com, linux-spi@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, John Madieu Subject: [PATCH 3/3] spi: imx: Propagate prepare_transfer() error from spi_imx_setupxfer() Date: Fri, 1 May 2026 13:59:51 +0000 Message-Id: <20260501135951.2416527-4-john.madieu@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260501135951.2416527-1-john.madieu@gmail.com> References: <20260501135951.2416527-1-john.madieu@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" spi_imx_setupxfer() calls the per-variant prepare_transfer() callback and returns 0 unconditionally: spi_imx->devtype_data->prepare_transfer(spi_imx, spi, t); return 0; mx51_ecspi_prepare_transfer() can return -EINVAL when the requested word_delay does not fit in MX51_ECSPI_PERIOD_MASK. The error is detected after a partial set of register writes (CTRL: BL, clkdiv, SMC), so the controller is left in a partially-configured state and the transfer is then submitted as if setup succeeded. Propagate the return value. The other variants' prepare_transfer callbacks all return 0, so this is a no-op for them. Signed-off-by: John Madieu Reviewed-by: Frank Li --- drivers/spi/spi-imx.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 4e3dbd01d619..480d1e8b281f 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -1382,9 +1382,7 @@ static int spi_imx_setupxfer(struct spi_device *spi, spi_imx->target_burst =3D t->len; } =20 - spi_imx->devtype_data->prepare_transfer(spi_imx, spi, t); - - return 0; + return spi_imx->devtype_data->prepare_transfer(spi_imx, spi, t); } =20 static void spi_imx_sdma_exit(struct spi_imx_data *spi_imx) --=20 2.25.1