Skip to contentSkip to conversation

accel: ethosu: Fix shift overflow in cmd_to_addr()

PATCH In review Dan Carpenter 2 participants 2 messages Oct 29, 2025 – Feb 18

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 accel: ethosu: Fix shift overflow in cmd_to_addr()

The "((cmd[0] & 0xff0000) << 16)" shift is zero. This was intended to be (((u64)cmd[0] & 0xff0000) << 16). Move the cast to the correct location.

Fixes 5a5e9c0228e6 ("accel: Add Arm Ethos-U NPU driver")

---
From static analysis. Not tested.

 drivers/accel/ethosu/ethosu_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/accel/ethosu/ethosu_gem.c +1 -1
index 473b5f5d7514..7b073116314b 100644
@@ -154,7 +154,7 @@ static void cmd_state_init(struct cmd_state *st)
 
 static u64 cmd_to_addr(u32 *cmd)
 {
-	return ((u64)((cmd[0] & 0xff0000) << 16)) | cmd[1];
+	return (((u64)cmd[0] & 0xff0000) << 16) | cmd[1];
 }
 
 static u64 dma_length(struct ethosu_validated_cmdstream_info *info,
Signature · 1 line
2.51.0
maintainer
#1 lore raw
Quoted 11 lines · Dan Carpenter

The "((cmd[0] & 0xff0000) << 16)" shift is zero. This was intended to be (((u64)cmd[0] & 0xff0000) << 16). Move the cast to the correct location.

Fixes 5a5e9c0228e6 ("accel: Add Arm Ethos-U NPU driver")

---

Quoted 1 line

From static analysis. Not tested.

 drivers/accel/ethosu/ethosu_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Missed this one. Now applied.

Rob