Commit 5fd866fb authored by Marek Belisko's avatar Marek Belisko Committed by Greg Kroah-Hartman

staging: ft1000: Fix proc initialization handling.

Cleaning proc entries when error occures was not handled correctly.
So fix and also add proper cleaning.
Signed-off-by: default avatarMarek Belisko <marek.belisko@open-nandra.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 11588411
...@@ -193,32 +193,44 @@ static struct notifier_block ft1000_netdev_notifier = { ...@@ -193,32 +193,44 @@ static struct notifier_block ft1000_netdev_notifier = {
}; };
void int ft1000InitProc(struct net_device *dev)
ft1000InitProc (struct net_device *dev)
{ {
struct ft1000_info *info; struct ft1000_info *info;
struct proc_dir_entry *ft1000_proc_file; struct proc_dir_entry *ft1000_proc_file;
info = netdev_priv(dev); int ret = 0;
info = netdev_priv(dev);
info->ft1000_proc_dir = proc_mkdir (FT1000_PROC_DIR, FTNET_PROC); info->ft1000_proc_dir = proc_mkdir (FT1000_PROC_DIR, FTNET_PROC);
if (info->ft1000_proc_dir == NULL) if (info->ft1000_proc_dir == NULL) {
{ printk(KERN_WARNING "Unable to create %s dir.\n",
remove_proc_entry (FT1000_PROC_DIR, FTNET_PROC); FT1000_PROC_DIR);
ret = -EINVAL;
goto fail;
} }
ft1000_proc_file = ft1000_proc_file =
create_proc_read_entry (dev->name, 0644, info->ft1000_proc_dir, create_proc_read_entry (dev->name, 0644, info->ft1000_proc_dir,
ft1000ReadProc, dev); ft1000ReadProc, dev);
if (ft1000_proc_file == NULL) if (ft1000_proc_file == NULL) {
{ printk(KERN_WARNING "Unable to create /proc entry.\n");
remove_proc_entry (info->netdevname, info->ft1000_proc_dir); ret = -EINVAL;
goto fail_entry;
} }
snprintf (info->netdevname, IFNAMSIZ, "%s", dev->name); snprintf (info->netdevname, IFNAMSIZ, "%s", dev->name);
register_netdevice_notifier (&ft1000_netdev_notifier); ret = register_netdevice_notifier(&ft1000_netdev_notifier);
return; if (ret)
goto fail_notif;
return 0;
fail_notif:
remove_proc_entry(info->netdevname, info->ft1000_proc_dir);
fail_entry:
remove_proc_entry(FT1000_PROC_DIR, FTNET_PROC);
fail:
return ret;
} }
void void
......
...@@ -594,7 +594,7 @@ struct usb_interface; ...@@ -594,7 +594,7 @@ struct usb_interface;
int reg_ft1000_netdev(struct ft1000_device *ft1000dev, struct usb_interface *intf); int reg_ft1000_netdev(struct ft1000_device *ft1000dev, struct usb_interface *intf);
int ft1000_poll(void* dev_id); int ft1000_poll(void* dev_id);
void ft1000InitProc(struct net_device *dev); int ft1000InitProc(struct net_device *dev);
void ft1000CleanupProc(struct ft1000_info *info); void ft1000CleanupProc(struct ft1000_info *info);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment