The first kfree(pDevice) is pointless because pDevice is NULL. The
second kfree(pDevice) is a double free because pDevice is the driver's
private data and that is already freed by free_netdev(netdev). Also the
free_netdev() error path doesn't call usb_put_dev().
Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
udev = usb_get_dev(udev);
netdev = alloc_etherdev(sizeof(DEVICE_INFO));
-
if (!netdev) {
printk(KERN_ERR DEVICE_NAME ": allocate net device failed\n");
- kfree(pDevice);
+ rc = -ENOMEM;
goto err_nomem;
}
rc = register_netdev(netdev);
if (rc) {
printk(KERN_ERR DEVICE_NAME " Failed to register netdev\n");
- free_netdev(netdev);
- kfree(pDevice);
- return -ENODEV;
+ goto err_netdev;
}
usb_device_reset(pDevice);
return 0;
+err_netdev:
+ free_netdev(netdev);
err_nomem:
usb_put_dev(udev);
- return -ENOMEM;
+ return rc;
}
static void device_free_tx_bufs(PSDevice pDevice)