Patchwork [3/4] f_phonet: fix inverted memory allocation sizes

login
register
mail settings
Submitter Rémi Denis-Courmont
Date April 6, 2009, 3:02 p.m.
Message ID <1239030177-28783-3-git-send-email-remi.denis-courmont@nokia.com>
Download mbox | patch
Permalink /patch/25641/
State Not Applicable
Delegated to: David Miller
Headers show

Comments

Rémi Denis-Courmont - April 6, 2009, 3:02 p.m.
From: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>

Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
---
 drivers/usb/gadget/f_phonet.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

Patch

diff --git a/drivers/usb/gadget/f_phonet.c b/drivers/usb/gadget/f_phonet.c
index dff7bae..25e711f 100644
--- a/drivers/usb/gadget/f_phonet.c
+++ b/drivers/usb/gadget/f_phonet.c
@@ -570,9 +570,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;
 
@@ -597,9 +598,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;