The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 1/3] nvmem: sprd: Fix memory overflow issue during memcpy operation in efuse driver
@ 2023-12-08  6:11 Yanxin Huang
  2023-12-08  6:11 ` [PATCH 2/3] nvmem: sprd: Fix programming errors in efuse caused by incorrect parameters Yanxin Huang
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Yanxin Huang @ 2023-12-08  6:11 UTC (permalink / raw)
  To: Srinivas Kandagatla, Orson Zhai, Baolin Wang, Chunyan Zhang
  Cc: linux-kernel, huang yanxin, Wenming Wu

The efuse driver didn't determine the size of bytes, resulting in memory
overflow during memcpy operation.

Fixes: 096030e7f449 ("nvmem: sprd: Add Spreadtrum SoCs eFuse support")
Signed-off-by: Yanxin Huang <yanxin.huang@unisoc.com>
---
 drivers/nvmem/sprd-efuse.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvmem/sprd-efuse.c b/drivers/nvmem/sprd-efuse.c
index bb3105f3291f..24b63620d217 100644
--- a/drivers/nvmem/sprd-efuse.c
+++ b/drivers/nvmem/sprd-efuse.c
@@ -311,6 +311,7 @@ static int sprd_efuse_read(void *context, u32 offset, void *val, size_t bytes)
 	ret = sprd_efuse_raw_read(efuse, index, &data, blk_double);
 	if (!ret) {
 		data >>= blk_offset;
+		bytes = bytes > sizeof(data) ? sizeof(data) : bytes;
 		memcpy(val, &data, bytes);
 	}
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-12-12  3:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-08  6:11 [PATCH 1/3] nvmem: sprd: Fix memory overflow issue during memcpy operation in efuse driver Yanxin Huang
2023-12-08  6:11 ` [PATCH 2/3] nvmem: sprd: Fix programming errors in efuse caused by incorrect parameters Yanxin Huang
2023-12-12  3:28   ` Baolin Wang
2023-12-08  6:11 ` [PATCH 3/3] nvmem: sprd: Remove the lock operation to support customers being able to program efuse multiple times Yanxin Huang
2023-12-12  3:37   ` Baolin Wang
2023-12-08 11:41 ` [PATCH 1/3] nvmem: sprd: Fix memory overflow issue during memcpy operation in efuse driver Srinivas Kandagatla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox