Commit ce14f8946a294ffa741ec29558a1c7e455cecd3b
Committed by
David S. Miller
1 parent
68d5ac2ed6
Exists in
master
and in
7 other branches
pktgen: refactor pg_init() code
This also shrinks the object size a little. text data bss dec hex filename 28834 186 8 29028 7164 net/core/pktgen.o 28816 186 8 29010 7152 net/core/pktgen.o.AFTER Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com> Cc: "David Miller" <davem@davemloft.net>, Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 1 changed file with 12 additions and 7 deletions Side-by-side Diff
net/core/pktgen.c
... | ... | @@ -3707,6 +3707,7 @@ |
3707 | 3707 | { |
3708 | 3708 | int cpu; |
3709 | 3709 | struct proc_dir_entry *pe; |
3710 | + int ret = 0; | |
3710 | 3711 | |
3711 | 3712 | pr_info("%s", version); |
3712 | 3713 | |
3713 | 3714 | |
... | ... | @@ -3717,11 +3718,10 @@ |
3717 | 3718 | pe = proc_create(PGCTRL, 0600, pg_proc_dir, &pktgen_fops); |
3718 | 3719 | if (pe == NULL) { |
3719 | 3720 | pr_err("ERROR: cannot create %s procfs entry\n", PGCTRL); |
3720 | - proc_net_remove(&init_net, PG_PROC_DIR); | |
3721 | - return -EINVAL; | |
3721 | + ret = -EINVAL; | |
3722 | + goto remove_dir; | |
3722 | 3723 | } |
3723 | 3724 | |
3724 | - /* Register us to receive netdevice events */ | |
3725 | 3725 | register_netdevice_notifier(&pktgen_notifier_block); |
3726 | 3726 | |
3727 | 3727 | for_each_online_cpu(cpu) { |
3728 | 3728 | |
... | ... | @@ -3735,13 +3735,18 @@ |
3735 | 3735 | |
3736 | 3736 | if (list_empty(&pktgen_threads)) { |
3737 | 3737 | pr_err("ERROR: Initialization failed for all threads\n"); |
3738 | - unregister_netdevice_notifier(&pktgen_notifier_block); | |
3739 | - remove_proc_entry(PGCTRL, pg_proc_dir); | |
3740 | - proc_net_remove(&init_net, PG_PROC_DIR); | |
3741 | - return -ENODEV; | |
3738 | + ret = -ENODEV; | |
3739 | + goto unregister; | |
3742 | 3740 | } |
3743 | 3741 | |
3744 | 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 | 3752 | static void __exit pg_cleanup(void) |