[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231208061134.26354-1-yanxin.huang@unisoc.com>
Date: Fri, 8 Dec 2023 14:11:32 +0800
From: Yanxin Huang <yanxin.huang@...soc.com>
To: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
Orson Zhai <orsonzhai@...il.com>,
Baolin Wang <baolin.wang@...ux.alibaba.com>,
Chunyan Zhang <zhang.lyra@...il.com>
CC: <linux-kernel@...r.kernel.org>,
huang yanxin <yanxin.huang07@...il.com>,
Wenming Wu <wenming.wu@...soc.com>
Subject: [PATCH 1/3] nvmem: sprd: Fix memory overflow issue during memcpy operation in efuse driver
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@...soc.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
Powered by blists - more mailing lists