usb: c67x00: fix uninitialized data access
Subsystems (2)
PATCH 1/1 usb: c67x00: fix uninitialized data access
From: Arnd Bergmann <[email protected]>
Randconfig builds for s390 using gcc-10.5 revealed that the c67x00_ll_husb_init_host_port() writes bogus data into the registers:
drivers/usb/c67x00/c67x00-ll-hpi.c: In function 'c67x00_ll_husb_init_host_port':drivers/usb/c67x00/c67x00-ll-hpi.c:288:3: error: '*(u16 *)((char *)&data+-452)' is used uninitialized in this function [-Werror=uninitialized]
288 | hpi_write_word(dev, COMM_R(i), data->regs[i]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I have not seen this error before, but the compiler is clearly correct and the bug has been in the driver since it was added in 2008. This particular build has CONFIG_INIT_STACK_NONE=y and CONFIG_UBSAN=y, but I don't think that alone is sufficient to find the bug.
Change this to write zeroes instead, which may still not be what is intended but at least avoids the undefined behavior and the warning about it.
--- drivers/usb/c67x00/c67x00-ll-hpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/c67x00/c67x00-ll-hpi.c +1 -1
@@ -306,7 +306,7 @@ void c67x00_ll_set_husb_eot(struct c67x00_device *dev, u16 value)static inline void c67x00_ll_husb_sie_init (struct c67x00_sie *sie) {struct c67x00_device *dev = sie->dev; -struct c67x00_lcp_int_data data; +struct c67x00_lcp_int_data data = {};int rc; rc =c67x00_comm_exec_int (dev,HUSB_SIE_INIT_INT (sie->sie_num), &data);
Signature · 1 line
2.53.0
Quoted 12 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Arnd" == Arnd Bergmann <[email protected]> writes:
From: Arnd Bergmann <[email protected]>
Randconfig builds for s390 using gcc-10.5 revealed that thec67x00_ll_husb_init_host_port()writes bogus data into the registers:
drivers/usb/c67x00/c67x00-ll-hpi.c: In function 'c67x00_ll_husb_init_host_port':drivers/usb/c67x00/c67x00-ll-hpi.c:288:3: error: '*(u16 *)((char *)&data+-452)' is used uninitialized in this function [-Werror=uninitialized]288 | hpi_write_word(dev, COMM_R(i), data->regs[i]); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 8 lines
I have not seen this error before, but the compiler is clearly correct and the bug has been in the driver since it was added in 2008. This particular build has
CONFIG_INIT_STACK_NONE=yandCONFIG_UBSAN=y, but I don't think that alone is sufficient to find the bug.Change this to write zeroes instead, which may still not be what is intended but at least avoids the undefined behavior and the warning about it.
Sorry, I don't have access to the documentation anymore :/
Quoted 2 lines
Fixes e9b29ffc519b ("USB: add Cypress c67x00 OTG controller HCD driver")Signed-off-by Arnd Bergmann <[email protected]>
I wonder if we have any users anymore? I have myself not have access to any platforms with this cypress controller for the last 10+ years or so, so maybe the driver should just be dropped?
Quoted 20 lines
--- drivers/usb/c67x00/c67x00-ll-hpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/c67x00/c67x00-ll-hpi.c +1
-1@@ -306,7 +306,7 @@ void c67x00_ll_set_husb_eot(struct c67x00_device *dev, u16 value)static inline void c67x00_ll_husb_sie_init (struct c67x00_sie *sie) {struct c67x00_device *dev = sie->dev; -struct c67x00_lcp_int_data data; +struct c67x00_lcp_int_data data = {};int rc; rc =c67x00_comm_exec_int (dev,HUSB_SIE_INIT_INT (sie->sie_num), &data);Signature · 1 line
2.53.0
Signature · 1 line
Bye, Peter Korsgaard