[PATCH] nvmem: make the misaligned raw_len non-fatal

Dmitry Baryshkov posted 1 patch 9 months, 4 weeks ago
drivers/nvmem/core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
[PATCH] nvmem: make the misaligned raw_len non-fatal
Posted by Dmitry Baryshkov 9 months, 4 weeks ago
The commit 11ccaa312111 ("nvmem: core: verify cell's raw_len") enforced
the raw read len being aligned to the NVMEM's word_size. However this
change broke some of the platforms, because those used misaligned
reads. Make this error non-fatal for the drivers that didn't specify
raw_len directly and just increase the raw_len making it aligned.

Fixes: 11ccaa312111 ("nvmem: core: verify cell's raw_len")
Reported-by: Mark Brown <broonie@kernel.org>
Closes: https://lore.kernel.org/linux-arm-msm/Z7Xv9lNc6ckJVtKc@finisterre.sirena.org.uk/
Tested-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 drivers/nvmem/core.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index b6f8544fd9662cff0a04e292bb536418564f0368..e206efc29a0044739f9d56e1b131af2809365201 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -612,7 +612,11 @@ static int nvmem_cell_info_to_nvmem_cell_entry_nodup(struct nvmem_device *nvmem,
 			"cell %s raw len %zd unaligned to nvmem word size %d\n",
 			cell->name ?: "<unknown>", cell->raw_len,
 			nvmem->word_size);
-		return -EINVAL;
+
+		if (info->raw_len)
+			return -EINVAL;
+
+		cell->raw_len = ALIGN(cell->raw_len, nvmem->word_size);
 	}
 
 	return 0;

---
base-commit: 8936cec5cb6e27649b86fabf383d7ce4113bba49
change-id: 20250220-nvmem-word-size-align-b9594a876569

Best regards,
-- 
Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Re: [PATCH] nvmem: make the misaligned raw_len non-fatal
Posted by Srinivas Kandagatla 9 months, 4 weeks ago
On Thu, 20 Feb 2025 21:49:30 +0200, Dmitry Baryshkov wrote:
> The commit 11ccaa312111 ("nvmem: core: verify cell's raw_len") enforced
> the raw read len being aligned to the NVMEM's word_size. However this
> change broke some of the platforms, because those used misaligned
> reads. Make this error non-fatal for the drivers that didn't specify
> raw_len directly and just increase the raw_len making it aligned.
> 
> 
> [...]

Applied, thanks!

[1/1] nvmem: make the misaligned raw_len non-fatal
      commit: d0ee061dec068a8c8700b51b08a7b7898cc66a2e

Best regards,
-- 
Srinivas Kandagatla <srinivas.kandagatla@linaro.org>