summaryrefslogtreecommitdiffstats
path: root/drivers/staging/ft1000
diff options
context:
space:
mode:
authorMarek Belisko <marek.belisko@open-nandra.com>2010-12-09 16:13:47 +0100
committerGreg Kroah-Hartman <gregkh@suse.de>2010-12-09 16:35:13 -0800
commit5fd866fb6401cf6a912e75e1b9c4b906bf42434e (patch)
tree1a5976f6a7a69856e15c4d2b5c6b96603e49706e /drivers/staging/ft1000
parent115884118a65c18af290476e44ca6c76a2c0a694 (diff)
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: Marek Belisko <marek.belisko@open-nandra.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/ft1000')
-rw-r--r--drivers/staging/ft1000/ft1000-usb/ft1000_proc.c40
-rw-r--r--drivers/staging/ft1000/ft1000-usb/ft1000_usb.h2
2 files changed, 27 insertions, 15 deletions
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c b/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c
index 105846d104f..dbd4a1ce9f5 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_proc.c
@@ -193,32 +193,44 @@ static struct notifier_block ft1000_netdev_notifier = {
};
-void
-ft1000InitProc (struct net_device *dev)
+int ft1000InitProc(struct net_device *dev)
{
struct ft1000_info *info;
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);
- if (info->ft1000_proc_dir == NULL)
- {
- remove_proc_entry (FT1000_PROC_DIR, FTNET_PROC);
- }
-
+ if (info->ft1000_proc_dir == NULL) {
+ printk(KERN_WARNING "Unable to create %s dir.\n",
+ FT1000_PROC_DIR);
+ ret = -EINVAL;
+ goto fail;
+ }
ft1000_proc_file =
create_proc_read_entry (dev->name, 0644, info->ft1000_proc_dir,
ft1000ReadProc, dev);
- if (ft1000_proc_file == NULL)
- {
- remove_proc_entry (info->netdevname, info->ft1000_proc_dir);
- }
+ if (ft1000_proc_file == NULL) {
+ printk(KERN_WARNING "Unable to create /proc entry.\n");
+ ret = -EINVAL;
+ goto fail_entry;
+ }
snprintf (info->netdevname, IFNAMSIZ, "%s", dev->name);
- register_netdevice_notifier (&ft1000_netdev_notifier);
- return;
+ ret = register_netdevice_notifier(&ft1000_netdev_notifier);
+ 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
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
index 045ef30b79a..4a91469e64f 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_usb.h
@@ -594,7 +594,7 @@ struct usb_interface;
int reg_ft1000_netdev(struct ft1000_device *ft1000dev, struct usb_interface *intf);
int ft1000_poll(void* dev_id);
-void ft1000InitProc(struct net_device *dev);
+int ft1000InitProc(struct net_device *dev);
void ft1000CleanupProc(struct ft1000_info *info);