* [PATCH] usb: musb: tusb6010: uninitialized data in tusb_fifo_write_unaligned()
@ 2021-09-15 10:36 Dan Carpenter
2021-09-15 17:49 ` Christophe JAILLET
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2021-09-15 10:36 UTC (permalink / raw)
To: Bin Liu, Felipe Balbi; +Cc: Greg Kroah-Hartman, linux-usb, kernel-janitors
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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/usb/musb/tusb6010.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
index c42937692207..c510fb84faa6 100644
--- a/drivers/usb/musb/tusb6010.c
+++ b/drivers/usb/musb/tusb6010.c
@@ -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);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: musb: tusb6010: uninitialized data in tusb_fifo_write_unaligned()
2021-09-15 10:36 [PATCH] usb: musb: tusb6010: uninitialized data in tusb_fifo_write_unaligned() Dan Carpenter
@ 2021-09-15 17:49 ` Christophe JAILLET
2021-09-16 7:46 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2021-09-15 17:49 UTC (permalink / raw)
To: Dan Carpenter, Bin Liu, Felipe Balbi
Cc: Greg Kroah-Hartman, linux-usb, kernel-janitors
Le 15/09/2021 à 12:36, Dan Carpenter a écrit :
> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/usb/musb/tusb6010.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
> index c42937692207..c510fb84faa6 100644
> --- a/drivers/usb/musb/tusb6010.c
> +++ b/drivers/usb/musb/tusb6010.c
> @@ -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;
?
> memcpy(&val, buf, len);
> musb_writel(fifo, 0, val);
> }
>
CJ
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: musb: tusb6010: uninitialized data in tusb_fifo_write_unaligned()
2021-09-15 17:49 ` Christophe JAILLET
@ 2021-09-16 7:46 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-09-16 7:46 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Bin Liu, Felipe Balbi, Greg Kroah-Hartman, linux-usb, kernel-janitors
On Wed, Sep 15, 2021 at 07:49:40PM +0200, Christophe JAILLET wrote:
> Le 15/09/2021 à 12:36, Dan Carpenter a écrit :
> > 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")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > drivers/usb/musb/tusb6010.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c
> > index c42937692207..c510fb84faa6 100644
> > --- a/drivers/usb/musb/tusb6010.c
> > +++ b/drivers/usb/musb/tusb6010.c
> > @@ -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;
> ?
Wow. Duh! My goodness...
Thanks for catching that.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-16 7:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-15 10:36 [PATCH] usb: musb: tusb6010: uninitialized data in tusb_fifo_write_unaligned() Dan Carpenter
2021-09-15 17:49 ` Christophe JAILLET
2021-09-16 7:46 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).