Skip to contentSkip to conversation

usb: musb: tusb6010: uninitialized data in tusb_fifo_write_unaligned()

PATCH Superseded Dan Carpenter 2 participants 3 messages Sep 15, 2021 – Sep 16, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: musb: tusb6010: uninitialized data in tusb_fifo_write_unaligned()

This is writing to the first 1 - 3 bytes of "len" and then writing all four bytes to musb_writel(). The last byte is always going to be garbage. Zero out the last bytes instead.

Fixes 550a7375fe72 ("USB: Add MUSB and TUSB support")
---
 drivers/usb/musb/tusb6010.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/musb/tusb6010.c +1 -0
index c42937692207..c510fb84faa6 100644
@@ -190,6 +190,7 @@ tusb_fifo_write_unaligned(void __iomem *fifo, const u8 *buf, u16 len)
 	}
 	if (len > 0) {
 		/* Write the rest 1 - 3 bytes to FIFO */
+		len = 0;
 		memcpy(&val, buf, len);
 		musb_writel(fifo, 0, val);
 	}
Signature · 1 line
2.20.1
#1 lore raw

Le 15/09/2021 à 12:36, Dan Carpenter a écrit :

Quoted 15 lines

This is writing to the first 1 - 3 bytes of "len" and then writing all four bytes to musb_writel(). The last byte is always going to be garbage. Zero out the last bytes instead.

Fixes 550a7375fe72 ("USB: Add MUSB and TUSB support")
---
  drivers/usb/musb/tusb6010.c | 1 +
  1 file changed, 1 insertion(+)
drivers/usb/musb/tusb6010.c +0 -0
index c42937692207..c510fb84faa6 100644

drivers/usb/musb/tusb6010.c tusb_fifo_write_unaligned(void __iomem *fifo, const u8 *buf, u16 len) · line 193

Quoted 4 lines
drivers/usb/musb/tusb6010.c +1 -0
@@ -190,6 +190,7 @@ tusb_fifo_write_unaligned(void __iomem *fifo, const u8 *buf, u16 len)
  	}
  	if (len > 0) {
  		/* Write the rest 1 - 3 bytes to FIFO */
+		len = 0;

+ val = 0;
?

drivers/usb/musb/tusb6010.c tusb_fifo_write_unaligned(void __iomem *fifo, const u8 *buf, u16 len) · line 196

Quoted 4 lines
drivers/usb/musb/tusb6010.c +0 -0
  		memcpy(&val, buf, len);
  		musb_writel(fifo, 0, val);
  	}

CJ

#2 lore raw
Quoted 22 lines · Christophe JAILLET

Le 15/09/2021 à 12:36, Dan Carpenter a écrit :

Quoted 19 lines

This is writing to the first 1 - 3 bytes of "len" and then writing all four bytes to musb_writel(). The last byte is always going to be garbage. Zero out the last bytes instead.

Fixes 550a7375fe72 ("USB: Add MUSB and TUSB support")
---
  drivers/usb/musb/tusb6010.c | 1 +
  1 file changed, 1 insertion(+)
drivers/usb/musb/tusb6010.c +1 -0
index c42937692207..c510fb84faa6 100644
@@ -190,6 +190,7 @@ tusb_fifo_write_unaligned(void __iomem *fifo, const u8 *buf, u16 len)
  	}
  	if (len > 0) {
  		/* Write the rest 1 - 3 bytes to FIFO */
+		len = 0;
(quoted diff) +1 -0
+		val = 0;
Quoted 1 line

?

Wow. Duh! My goodness...

Thanks for catching that.

regards,
dan carpenter