usb: gadget: f_phonet: fix memory allocation sizes
authorRémi Denis-Courmont <remi.denis-courmont@nokia.com>
Mon, 1 Jun 2009 01:18:57 +0000 (01:18 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 2 Jun 2009 07:17:46 +0000 (00:17 -0700)
Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/usb/gadget/f_phonet.c

index d6b48714d8998ee0c8f7fde97e51758f73da8c96..96fb118355b0492d8350ff8524760290a4441de1 100644 (file)
@@ -569,9 +569,10 @@ static struct net_device *dev;
 int __init phonet_bind_config(struct usb_configuration *c)
 {
        struct f_phonet *fp;
-       int err;
+       int err, size;
 
-       fp = kzalloc(sizeof(*fp), GFP_KERNEL);
+       size = sizeof(*fp) + (phonet_rxq_size * sizeof(struct usb_request *));
+       fp = kzalloc(size, GFP_KERNEL);
        if (!fp)
                return -ENOMEM;
 
@@ -596,9 +597,7 @@ int __init gphonet_setup(struct usb_gadget *gadget)
 
        /* Create net device */
        BUG_ON(dev);
-       dev = alloc_netdev(sizeof(*port)
-               + (phonet_rxq_size * sizeof(struct usb_request *)),
-                               "upnlink%d", pn_net_setup);
+       dev = alloc_netdev(sizeof(*port), "upnlink%d", pn_net_setup);
        if (!dev)
                return -ENOMEM;