USB: FHCI: Correct the size argument to kzalloc
authorJulia Lawall <julia@diku.dk>
Wed, 30 Dec 2009 14:34:37 +0000 (15:34 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 2 Mar 2010 22:54:00 +0000 (14:54 -0800)
urb_priv->tds has type struct td **, not struct td *, so the
elements of the array should have pointer type, not structure type.

Convert kzalloc to kcalloc as well.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@disable sizeof_type_expr@
type T;
T **x;
@@

  x =
  <+...sizeof(
- T
+ *x
  )...+>
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/host/fhci-hcd.c

index 78e7c3c..ed4b87c 100644 (file)
@@ -433,7 +433,7 @@ static int fhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
                return -ENOMEM;
 
        /* allocate the private part of the URB */
-       urb_priv->tds = kzalloc(size * sizeof(struct td), mem_flags);
+       urb_priv->tds = kcalloc(size, sizeof(*urb_priv->tds), mem_flags);
        if (!urb_priv->tds) {
                kfree(urb_priv);
                return -ENOMEM;