Skip to contentSkip to conversation

nvmem: rockchip-otp: initialize ret in rk3588_otp_read

PATCH In review Ruoyu Wang 2 participants 2 messages Jun 17

Subsystems (2)
lore
Share & tools
lore

Ruoyu Wang

author
#0 lore raw

PATCH 1/1 nvmem: rockchip-otp: initialize ret in rk3588_otp_read

rk3588_otp_read() returns ret after a count-controlled loop. If count is zero, the loop is skipped and ret is not assigned. Initialize ret to 0 for the empty read path.

---
 drivers/nvmem/rockchip-otp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvmem/rockchip-otp.c +1 -1
index 0ec78b5e19e7d..50a19b6dc4027 100644
@@ -242,7 +242,7 @@ static int rk3588_otp_read(void *context, unsigned int offset,
 {
 	struct rockchip_otp *otp = context;
 	u32 *buf = val;
-	int ret;
+	int ret = 0;
 
 	while (count--) {
 		writel((offset++ << RK3588_ADDR_SHIFT) |
Signature · 1 line
2.51.0
#1 lore raw

Hi Ruoyu,

Quoted 3 lines · Ruoyu Wang

rk3588_otp_read() returns ret after a count-controlled loop. If count is zero, the loop is skipped and ret is not assigned. Initialize ret to 0 for the empty read path.

To my knowledge core will protect against bytes<=0 read, if that is not the case we should likely fix so that rockchip_otp_read() never calls the internal reg_read ops with bytes/count<=0.

Regards,
Jonas

Quoted 19 lines
---
 drivers/nvmem/rockchip-otp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvmem/rockchip-otp.c +1 -1
index 0ec78b5e19e7d..50a19b6dc4027 100644
@@ -242,7 +242,7 @@ static int rk3588_otp_read(void *context, unsigned int offset,
 {
 	struct rockchip_otp *otp = context;
 	u32 *buf = val;
-	int ret;
+	int ret = 0;
 
 	while (count--) {
 		writel((offset++ << RK3588_ADDR_SHIFT) |