diff options
-rw-r--r-- | net/core/pktgen.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 3b85c0dffa6..f76079cd750 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -3707,6 +3707,7 @@ static int __init pg_init(void) | |||
3707 | { | 3707 | { |
3708 | int cpu; | 3708 | int cpu; |
3709 | struct proc_dir_entry *pe; | 3709 | struct proc_dir_entry *pe; |
3710 | int ret = 0; | ||
3710 | 3711 | ||
3711 | pr_info("%s", version); | 3712 | pr_info("%s", version); |
3712 | 3713 | ||
@@ -3717,11 +3718,10 @@ static int __init pg_init(void) | |||
3717 | pe = proc_create(PGCTRL, 0600, pg_proc_dir, &pktgen_fops); | 3718 | pe = proc_create(PGCTRL, 0600, pg_proc_dir, &pktgen_fops); |
3718 | if (pe == NULL) { | 3719 | if (pe == NULL) { |
3719 | pr_err("ERROR: cannot create %s procfs entry\n", PGCTRL); | 3720 | pr_err("ERROR: cannot create %s procfs entry\n", PGCTRL); |
3720 | proc_net_remove(&init_net, PG_PROC_DIR); | 3721 | ret = -EINVAL; |
3721 | return -EINVAL; | 3722 | goto remove_dir; |
3722 | } | 3723 | } |
3723 | 3724 | ||
3724 | /* Register us to receive netdevice events */ | ||
3725 | register_netdevice_notifier(&pktgen_notifier_block); | 3725 | register_netdevice_notifier(&pktgen_notifier_block); |
3726 | 3726 | ||
3727 | for_each_online_cpu(cpu) { | 3727 | for_each_online_cpu(cpu) { |
@@ -3735,13 +3735,18 @@ static int __init pg_init(void) | |||
3735 | 3735 | ||
3736 | if (list_empty(&pktgen_threads)) { | 3736 | if (list_empty(&pktgen_threads)) { |
3737 | pr_err("ERROR: Initialization failed for all threads\n"); | 3737 | pr_err("ERROR: Initialization failed for all threads\n"); |
3738 | unregister_netdevice_notifier(&pktgen_notifier_block); | 3738 | ret = -ENODEV; |
3739 | remove_proc_entry(PGCTRL, pg_proc_dir); | 3739 | goto unregister; |
3740 | proc_net_remove(&init_net, PG_PROC_DIR); | ||
3741 | return -ENODEV; | ||
3742 | } | 3740 | } |
3743 | 3741 | ||
3744 | return 0; | 3742 | return 0; |
3743 | |||
3744 | unregister: | ||
3745 | unregister_netdevice_notifier(&pktgen_notifier_block); | ||
3746 | remove_proc_entry(PGCTRL, pg_proc_dir); | ||
3747 | remove_dir: | ||
3748 | proc_net_remove(&init_net, PG_PROC_DIR); | ||
3749 | return ret; | ||
3745 | } | 3750 | } |
3746 | 3751 | ||
3747 | static void __exit pg_cleanup(void) | 3752 | static void __exit pg_cleanup(void) |