Skip to content

Commit

Permalink
Allocate correct size (portably) in drivers/usb/gadget/f_midi.c::f_mi…
Browse files Browse the repository at this point in the history
…di_bind()

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>
  • Loading branch information
Jesper Juhl authored and Greg Kroah-Hartman committed Mar 3, 2012
1 parent b1443ac commit 2a5be87
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/usb/gadget/f_midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2a5be87

Please sign in to comment.