]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
Allocate correct size (portably) in drivers/usb/gadget/f_midi.c::f_midi_bind()
authorJesper Juhl <jj@chaosbits.net>
Thu, 1 Mar 2012 22:01:19 +0000 (23:01 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 3 Mar 2012 00:22:11 +0000 (16:22 -0800)
As the coverity checker puts it:

"Passing argument "sizeof (midi_function) /*8*/" to function "kcalloc"
and then casting the return value to "struct usb_descriptor_header **"
is suspicious. ... In this particular case sizeof(struct
usb_descriptor_header **) happens to be equal to sizeof(struct
usb_descriptor_header *), but this is not a portable assumption."

I believe we really do intend to use 'sizeof(*midi_function)' here, so
this patch makes that change.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/f_midi.c

index 3797b3d6c622bd49ff709b33303a86e323294c44..2f7e8f2930cc3367847ab68dc06ead22a2a6ab60 100644 (file)
@@ -780,7 +780,7 @@ f_midi_bind(struct usb_configuration *c, struct usb_function *f)
        midi->out_ep->driver_data = cdev;       /* claim */
 
        /* allocate temporary function list */
-       midi_function = kcalloc((MAX_PORTS * 4) + 9, sizeof(midi_function),
+       midi_function = kcalloc((MAX_PORTS * 4) + 9, sizeof(*midi_function),
                                GFP_KERNEL);
        if (!midi_function) {
                status = -ENOMEM;