From patchwork Fri Sep 13 21:07:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "lorenzo@kernel.org" X-Patchwork-Id: 13804077 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5C29126C01 for ; Fri, 13 Sep 2024 21:07:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726261661; cv=none; b=A+/JWR7bG1XpL2CFqbht3EeTXFjf7hf+UO87KWAgmDEoQEpabHgnRvMMN+3vYoY5yt6jLPlVCZ2YHa95s/gX1srXF3OYDjG2XufEzfTxQric3FYHa8p+yXoxEt4QTz1ZxWK7knOCJsaiWJLr1wvxgrDwgMZxXgUvW6w7p1MhxlI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726261661; c=relaxed/simple; bh=+TB9oObE8jFM8lByBhuspz+4OeFWOAzD//N1khf/Abo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=I+li2OP4GJAeQMSFMkU5uAbRefPqe4+B+a803zeeQ0Uu1F4D+R5YQMX+GgPBcWJlgfNB25EMbt9HgWY/cW/Oq2xLBa9hf3gQrQM+L/xrukFn5UsR8V+r8M0itYUcKLX2KdElw4N3MveOudrpWwntu65/6c0xxQZjD+nMms2pFrM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X5xqBXgs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="X5xqBXgs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69ACDC4CEC0; Fri, 13 Sep 2024 21:07:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726261660; bh=+TB9oObE8jFM8lByBhuspz+4OeFWOAzD//N1khf/Abo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=X5xqBXgsgcd9ObFakEuqbRgwvTe06H77CeQAVaw1UF/fofsX0aj6XVRFKSAqYM+l6 mAWT5alixveEBy+s/HG05AWEUX1/rV9vRYPrh8ORVADjDrGwrMI3gEwrECKYsF282L SgaY9kC81rA0Yr7Lab4J4RPcvJuiBU8eLcigE47fi4W8u5gm0ggebbzSB90io2MOp9 mBFPI/K2pA7kTFbHEAhwGQj4XI8WzR0C5p0rK2qrYdm7CBhGHMri3fnf83ZrjyZaGj 5/FAQblwIfGmyeK1wkfpNn6uCKHIXLkzSvFcdUD9o10dVQQIQK5xzrqk2cF3zt7Pk1 7E/NgLSjKa/lw== From: Lorenzo Bianconi Date: Fri, 13 Sep 2024 23:07:14 +0200 Subject: [PATCH 2/4] spi: airoha: fix airoha_snand_{write,read}_data data_len estimation Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240913-airoha-spi-fixes-v1-2-de2e74ed4664@kernel.org> References: <20240913-airoha-spi-fixes-v1-0-de2e74ed4664@kernel.org> In-Reply-To: <20240913-airoha-spi-fixes-v1-0-de2e74ed4664@kernel.org> To: Lorenzo Bianconi , Ray Liu , Mark Brown , AngeloGioacchino Del Regno , Andy Shevchenko Cc: Christian Marangi , linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org, upstream@airoha.com X-Mailer: b4 0.14.1 Fix data length written and read in airoha_snand_write_data and airoha_snand_read_data routines respectively if it is bigger than SPI_MAX_TRANSFER_SIZE. Fixes: a403997c1201 ("spi: airoha: add SPI-NAND Flash controller driver") Tested-by: Christian Marangi Signed-off-by: Lorenzo Bianconi --- drivers/spi/spi-airoha-snfi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-airoha-snfi.c b/drivers/spi/spi-airoha-snfi.c index be3e4ac42153..c71be702cf6f 100644 --- a/drivers/spi/spi-airoha-snfi.c +++ b/drivers/spi/spi-airoha-snfi.c @@ -405,7 +405,7 @@ static int airoha_snand_write_data(struct airoha_snand_ctrl *as_ctrl, u8 cmd, for (i = 0; i < len; i += data_len) { int err; - data_len = min(len, SPI_MAX_TRANSFER_SIZE); + data_len = min(len - i, SPI_MAX_TRANSFER_SIZE); err = airoha_snand_set_fifo_op(as_ctrl, cmd, data_len); if (err) return err; @@ -427,7 +427,7 @@ static int airoha_snand_read_data(struct airoha_snand_ctrl *as_ctrl, u8 *data, for (i = 0; i < len; i += data_len) { int err; - data_len = min(len, SPI_MAX_TRANSFER_SIZE); + data_len = min(len - i, SPI_MAX_TRANSFER_SIZE); err = airoha_snand_set_fifo_op(as_ctrl, 0xc, data_len); if (err) return err;