usb: xhci: fix incorrect memset()
Subsystems (2)
PATCH 1/1 usb: xhci: fix incorrect memset()
gcc-8 warnings about the new driver using a memset with a bogus length:
drivers/usb/host/xhci-dbgcap.c: In function 'xhci_dbc_eps_exit':drivers/usb/host/xhci-dbgcap.c:369:2: error: 'memset' used with length equal to number of elements without multiplication by element size [-Werror=memset-elt-size]
It looks like the author meant to use sizeof() rather than ARRAY_SIZE() here, so use that.
--- drivers/usb/host/xhci-dbgcap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-dbgcap.c +1 -1
@@ -366,7 +366,7 @@ static void xhci_dbc_eps_exit(struct xhci_hcd *xhci) {struct xhci_dbc *dbc = xhci->dbc; -memset (dbc->eps,0 ,ARRAY_SIZE (dbc->eps)); +memset (dbc->eps,0 ,sizeof (dbc->eps)); }static int xhci_dbc_mem_init (struct xhci_hcd *xhci,gfp_t flags)
Quoted 11 lines · Arnd Bergmann
gcc-8 warnings about the new driver using a memset with a bogus length:
drivers/usb/host/xhci-dbgcap.c: In function 'xhci_dbc_eps_exit':drivers/usb/host/xhci-dbgcap.c:369:2: error: 'memset' used with length equal to number of elements without multiplication by element size [-Werror=memset-elt-size]It looks like the author meant to use
sizeof()rather thanARRAY_SIZE()here, so use that.Fixes dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver")Signed-off-by Arnd Bergmann <[email protected]>---
Another patch to fix the same thing was sent earlier as a follow up to the original series.
https://marc.info/?l=linux-usb&m=151298133524873&w=2
But your patch includes the Fixes line with the commit id, which is nice.
Both fix the problem, It doesn't matter for me which one gets applied
Thanks
-Mathias
Greg Kroah-Hartman
maintainerQuoted 13 lines · Mathias Nyman
Quoted 11 lines · Arnd Bergmann
gcc-8 warnings about the new driver using a memset with a bogus length:
drivers/usb/host/xhci-dbgcap.c: In function 'xhci_dbc_eps_exit':drivers/usb/host/xhci-dbgcap.c:369:2: error: 'memset' used with length equal to number of elements without multiplication by element size [-Werror=memset-elt-size]It looks like the author meant to use
sizeof()rather thanARRAY_SIZE()here, so use that.Fixes dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver")Signed-off-by Arnd Bergmann <[email protected]>---
Quoted 6 lines
Another patch to fix the same thing was sent earlier as a follow up to the original series.
https://marc.info/?l=linux-usb&m=151298133524873&w=2But your patch includes the Fixes line with the commit id, which is nice.
Both fix the problem, It doesn't matter for me which one gets applied
They fix it in different ways, which is correct?
I'm guessing you tested yours? And Arnd probably doesn't have the hardware to do so?
thanks,
greg k-h
Quoted 14 lines · Greg Kroah-Hartman
Quoted 13 lines · Mathias Nyman
Quoted 11 lines · Arnd Bergmann
gcc-8 warnings about the new driver using a memset with a bogus length:
drivers/usb/host/xhci-dbgcap.c: In function 'xhci_dbc_eps_exit':drivers/usb/host/xhci-dbgcap.c:369:2: error: 'memset' used with length equal to number of elements without multiplication by element size [-Werror=memset-elt-size]It looks like the author meant to use
sizeof()rather thanARRAY_SIZE()here, so use that.Fixes dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver")Signed-off-by Arnd Bergmann <[email protected]>---
Quoted 8 lines
Quoted 6 lines
Another patch to fix the same thing was sent earlier as a follow up to the original series.
https://marc.info/?l=linux-usb&m=151298133524873&w=2But your patch includes the Fixes line with the commit id, which is nice.
Both fix the problem, It doesn't matter for me which one gets applied
They fix it in different ways, which is correct?
Both are correct, 'sizeof(dbc->eps)' is the same as 'sizeof(struct dbc_ep) * ARRAY_SIZE(dbc->eps)'.
Quoted 1 line
And Arnd probably doesn't have the hardware to do so?
Right.
Arnd
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 23 lines · Arnd Bergmann
Quoted 21 lines · Greg Kroah-Hartman
Quoted 19 lines · Mathias Nyman
Quoted 11 lines · Arnd Bergmann
gcc-8 warnings about the new driver using a memset with a bogus length:
drivers/usb/host/xhci-dbgcap.c: In function 'xhci_dbc_eps_exit':drivers/usb/host/xhci-dbgcap.c:369:2: error: 'memset' used with length equal to number of elements without multiplication by element size [-Werror=memset-elt-size]It looks like the author meant to use
sizeof()rather thanARRAY_SIZE()here, so use that.Fixes dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver")Signed-off-by Arnd Bergmann <[email protected]>---
Another patch to fix the same thing was sent earlier as a follow up to the original series.
https://marc.info/?l=linux-usb&m=151298133524873&w=2But your patch includes the Fixes line with the commit id, which is nice.
Both fix the problem, It doesn't matter for me which one gets applied
Quoted 9 lines
Quoted 1 line
They fix it in different ways, which is correct?
Both are correct, '
sizeof(dbc->eps)' is the same as 'sizeof(struct dbc_ep)*ARRAY_SIZE(dbc->eps)'.Quoted 1 line
And Arnd probably doesn't have the hardware to do so?
Right.
Just to test and confirm boyh work I added a couple printk messages after memset() showing bytes zeroed and method used:
# echo enabled > dbc # cat dbc enabled # [ 219.050277] xhci_hcd 0000:00:14.0: DbC connected [ 219.307250] xhci_hcd 0000:00:14.0: DbC configured [ 219.313601] xhci_hcd 0000:00:14.0: DbC now attached to /dev/ttyDBC0
# echo disabled > dbc [ 255.745590] xhci_hcd 0000:00:14.0: set 80 bytes to zero sizeof(struct dbc_ep) * ARRAY_SIZE(dbc->eps) [ 255.755970] xhci_hcd 0000:00:14.0: set 80 bytes to zero sizeof(dbc->eps)
-Mathias