* [PATCH] usb: xhci: fix incorrect memset()
@ 2017-12-11 11:27 ` Arnd Bergmann
0 siblings, 0 replies; 10+ messages in thread
From: Arnd Bergmann @ 2017-12-11 11:27 UTC (permalink / raw)
To: Mathias Nyman, Greg Kroah-Hartman
Cc: Arnd Bergmann, Lu Baolu, linux-usb, linux-kernel
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.
Fixes: dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/usb/host/xhci-dbgcap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c
index 671e5023e683..1e535bd2be01 100644
--- a/drivers/usb/host/xhci-dbgcap.c
+++ b/drivers/usb/host/xhci-dbgcap.c
@@ -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)
--
2.9.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* usb: xhci: fix incorrect memset()
@ 2017-12-11 11:27 ` Arnd Bergmann
0 siblings, 0 replies; 10+ messages in thread
From: Arnd Bergmann @ 2017-12-11 11:27 UTC (permalink / raw)
To: Mathias Nyman, Greg Kroah-Hartman
Cc: Arnd Bergmann, Lu Baolu, linux-usb, linux-kernel
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.
Fixes: dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/usb/host/xhci-dbgcap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c
index 671e5023e683..1e535bd2be01 100644
--- a/drivers/usb/host/xhci-dbgcap.c
+++ b/drivers/usb/host/xhci-dbgcap.c
@@ -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)
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] usb: xhci: fix incorrect memset()
@ 2017-12-11 12:59 ` Mathias Nyman
0 siblings, 0 replies; 10+ messages in thread
From: Mathias Nyman @ 2017-12-11 12:59 UTC (permalink / raw)
To: Arnd Bergmann, Mathias Nyman, Greg Kroah-Hartman
Cc: Lu Baolu, linux-usb, linux-kernel
On 11.12.2017 13:27, Arnd Bergmann wrote:
> 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.
>
> Fixes: dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* usb: xhci: fix incorrect memset()
@ 2017-12-11 12:59 ` Mathias Nyman
0 siblings, 0 replies; 10+ messages in thread
From: Mathias Nyman @ 2017-12-11 12:59 UTC (permalink / raw)
To: Arnd Bergmann, Mathias Nyman, Greg Kroah-Hartman
Cc: Lu Baolu, linux-usb, linux-kernel
On 11.12.2017 13:27, Arnd Bergmann wrote:
> 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.
>
> Fixes: dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
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
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] usb: xhci: fix incorrect memset()
@ 2017-12-11 17:01 ` Greg Kroah-Hartman
0 siblings, 0 replies; 10+ messages in thread
From: Greg Kroah-Hartman @ 2017-12-11 17:01 UTC (permalink / raw)
To: Mathias Nyman
Cc: Arnd Bergmann, Mathias Nyman, Lu Baolu, linux-usb, linux-kernel
On Mon, Dec 11, 2017 at 02:59:13PM +0200, Mathias Nyman wrote:
> On 11.12.2017 13:27, Arnd Bergmann wrote:
> > 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.
> >
> > Fixes: dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ---
>
> 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
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
^ permalink raw reply [flat|nested] 10+ messages in thread
* usb: xhci: fix incorrect memset()
@ 2017-12-11 17:01 ` Greg Kroah-Hartman
0 siblings, 0 replies; 10+ messages in thread
From: Greg Kroah-Hartman @ 2017-12-11 17:01 UTC (permalink / raw)
To: Mathias Nyman
Cc: Arnd Bergmann, Mathias Nyman, Lu Baolu, linux-usb, linux-kernel
On Mon, Dec 11, 2017 at 02:59:13PM +0200, Mathias Nyman wrote:
> On 11.12.2017 13:27, Arnd Bergmann wrote:
> > 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.
> >
> > Fixes: dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ---
>
> 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
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
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] usb: xhci: fix incorrect memset()
@ 2017-12-11 17:05 ` Arnd Bergmann
0 siblings, 0 replies; 10+ messages in thread
From: Arnd Bergmann @ 2017-12-11 17:05 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Mathias Nyman, Mathias Nyman, Lu Baolu, linux-usb,
Linux Kernel Mailing List
On Mon, Dec 11, 2017 at 6:01 PM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Mon, Dec 11, 2017 at 02:59:13PM +0200, Mathias Nyman wrote:
>> On 11.12.2017 13:27, Arnd Bergmann wrote:
>> > 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.
>> >
>> > Fixes: dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver")
>> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>> > ---
>>
>> 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
>
> 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)'.
> And Arnd probably doesn't have the hardware to do so?
Right.
Arnd
^ permalink raw reply [flat|nested] 10+ messages in thread
* usb: xhci: fix incorrect memset()
@ 2017-12-11 17:05 ` Arnd Bergmann
0 siblings, 0 replies; 10+ messages in thread
From: Arnd Bergmann @ 2017-12-11 17:05 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Mathias Nyman, Mathias Nyman, Lu Baolu, linux-usb,
Linux Kernel Mailing List
On Mon, Dec 11, 2017 at 6:01 PM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Mon, Dec 11, 2017 at 02:59:13PM +0200, Mathias Nyman wrote:
>> On 11.12.2017 13:27, Arnd Bergmann wrote:
>> > 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.
>> >
>> > Fixes: dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver")
>> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>> > ---
>>
>> 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
>
> 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)'.
> 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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] usb: xhci: fix incorrect memset()
@ 2017-12-12 10:47 ` Mathias Nyman
0 siblings, 0 replies; 10+ messages in thread
From: Mathias Nyman @ 2017-12-12 10:47 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman
Cc: Mathias Nyman, Lu Baolu, linux-usb, Linux Kernel Mailing List
On 11.12.2017 19:05, Arnd Bergmann wrote:
> On Mon, Dec 11, 2017 at 6:01 PM, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
>> On Mon, Dec 11, 2017 at 02:59:13PM +0200, Mathias Nyman wrote:
>>> On 11.12.2017 13:27, Arnd Bergmann wrote:
>>>> 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.
>>>>
>>>> Fixes: dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver")
>>>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>>>> ---
>>>
>>> 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
>>
>> 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)'.
>
>> 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
^ permalink raw reply [flat|nested] 10+ messages in thread
* usb: xhci: fix incorrect memset()
@ 2017-12-12 10:47 ` Mathias Nyman
0 siblings, 0 replies; 10+ messages in thread
From: Mathias Nyman @ 2017-12-12 10:47 UTC (permalink / raw)
To: Arnd Bergmann, Greg Kroah-Hartman
Cc: Mathias Nyman, Lu Baolu, linux-usb, Linux Kernel Mailing List
On 11.12.2017 19:05, Arnd Bergmann wrote:
> On Mon, Dec 11, 2017 at 6:01 PM, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
>> On Mon, Dec 11, 2017 at 02:59:13PM +0200, Mathias Nyman wrote:
>>> On 11.12.2017 13:27, Arnd Bergmann wrote:
>>>> 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.
>>>>
>>>> Fixes: dfba2174dc42 ("usb: xhci: Add DbC support in xHCI driver")
>>>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>>>> ---
>>>
>>> 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
>>
>> 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)'.
>
>> 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
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-12-12 10:47 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-11 11:27 [PATCH] usb: xhci: fix incorrect memset() Arnd Bergmann
2017-12-11 11:27 ` Arnd Bergmann
2017-12-11 12:59 ` [PATCH] " Mathias Nyman
2017-12-11 12:59 ` Mathias Nyman
2017-12-11 17:01 ` [PATCH] " Greg Kroah-Hartman
2017-12-11 17:01 ` Greg Kroah-Hartman
2017-12-11 17:05 ` [PATCH] " Arnd Bergmann
2017-12-11 17:05 ` Arnd Bergmann
2017-12-12 10:47 ` [PATCH] " Mathias Nyman
2017-12-12 10:47 ` Mathias Nyman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.