Skip to contentSkip to conversation

nvmem: fixes for v7.0

PATCH New [email protected] 1 participant 3 messages Mar 27

Subsystems (5)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

cover nvmem: fixes for v7.0

From: Srinivas Kandagatla <[email protected]>

Hi Greg,

Here are two nvmem fixes which can go for 7.0 release If its not too late, could you please queue these as 7.0 material.

Thanks for all the help,
Srini

Christian Eggers (1):
nvmem: imx: assign nvmem_cell_info::raw_len

Ivan Vera (1):
nvmem: zynqmp_nvmem: Fix buffer size in DMA and memcpy

 drivers/nvmem/imx-ocotp-ele.c | 1 +
 drivers/nvmem/imx-ocotp.c     | 1 +
 drivers/nvmem/zynqmp_nvmem.c  | 8 ++++----
 3 files changed, 6 insertions(+), 4 deletions(-)
Signature · 1 line
2.47.3
author maintainer
#1 lore raw

PATCH 1/2 nvmem: imx: assign nvmem_cell_info::raw_len

From: Christian Eggers <[email protected]>

Avoid getting error messages at startup like the following on i.MX6ULL:

nvmem imx-ocotp0: cell mac-addr raw len 6 unaligned to nvmem word size 4 nvmem imx-ocotp0: cell mac-addr raw len 6 unaligned to nvmem word size 4

This shouldn't cause any functional change as this alignment would otherwise be done in nvmem_cell_info_to_nvmem_cell_entry_nodup().

Fixes 13bcd440f2ff ("nvmem: core: verify cell's raw_len")
---
 drivers/nvmem/imx-ocotp-ele.c | 1 +
 drivers/nvmem/imx-ocotp.c     | 1 +
 2 files changed, 2 insertions(+)
drivers/nvmem/imx-ocotp-ele.c +1 -0
index 7cf7e809a8f5..a0d2985c6d03 100644
@@ -131,6 +131,7 @@ static int imx_ocotp_cell_pp(void *context, const char *id, int index,
 static void imx_ocotp_fixup_dt_cell_info(struct nvmem_device *nvmem,
 					 struct nvmem_cell_info *cell)
 {
+	cell->raw_len = round_up(cell->bytes, 4);
 	cell->read_post_process = imx_ocotp_cell_pp;
 }
 
drivers/nvmem/imx-ocotp.c +1 -0
index 7bf7656d4f96..108d78d7f6cb 100644
@@ -589,6 +589,7 @@ MODULE_DEVICE_TABLE(of, imx_ocotp_dt_ids);
 static void imx_ocotp_fixup_dt_cell_info(struct nvmem_device *nvmem,
 					 struct nvmem_cell_info *cell)
 {
+	cell->raw_len = round_up(cell->bytes, 4);
 	cell->read_post_process = imx_ocotp_cell_pp;
 }
 
Signature · 1 line
2.47.3
author maintainer
#2 lore raw

PATCH 2/2 nvmem: zynqmp_nvmem: Fix buffer size in DMA and memcpy

In reply to [email protected]

From: Ivan Vera <[email protected]>

Buffer size used in dma allocation and memcpy is wrong. It can lead to undersized DMA buffer access and possible memory corruption. use correct buffer size in dma_alloc_coherent and memcpy.

Fixes 737c0c8d07b5 ("nvmem: zynqmp_nvmem: Add support to access efuse")
---
 drivers/nvmem/zynqmp_nvmem.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/nvmem/zynqmp_nvmem.c +4 -4
index 7da717d6c7fa..d297ff150dc0 100644
@@ -66,7 +66,7 @@ static int zynqmp_efuse_access(void *context, unsigned int offset,
 	dma_addr_t dma_buf;
 	size_t words = bytes / WORD_INBYTES;
 	int ret;
-	int value;
+	unsigned int value;
 	char *data;
 
 	if (bytes % WORD_INBYTES != 0) {
@@ -80,7 +80,7 @@ static int zynqmp_efuse_access(void *context, unsigned int offset,
 	}
 
 	if (pufflag == 1 && flag == EFUSE_WRITE) {
-		memcpy(&value, val, bytes);
+		memcpy(&value, val, sizeof(value));
 		if ((offset == EFUSE_PUF_START_OFFSET ||
 		     offset == EFUSE_PUF_MID_OFFSET) &&
 		    value & P_USER_0_64_UPPER_MASK) {
@@ -100,7 +100,7 @@ static int zynqmp_efuse_access(void *context, unsigned int offset,
 	if (!efuse)
 		return -ENOMEM;
 
-	data = dma_alloc_coherent(dev, sizeof(bytes),
+	data = dma_alloc_coherent(dev, bytes,
 				  &dma_buf, GFP_KERNEL);
 	if (!data) {
 		ret = -ENOMEM;
@@ -134,7 +134,7 @@ static int zynqmp_efuse_access(void *context, unsigned int offset,
 	if (flag == EFUSE_READ)
 		memcpy(val, data, bytes);
 efuse_access_err:
-	dma_free_coherent(dev, sizeof(bytes),
+	dma_free_coherent(dev, bytes,
 			  data, dma_buf);
 efuse_data_fail:
 	dma_free_coherent(dev, sizeof(struct xilinx_efuse),
Signature · 1 line
2.47.3