Skip to content

Commit 25296d5

Browse files
Wang Chendavem330
authored andcommitted
[PKTGEN]: Use proc_create() to setup ->proc_fops first
Use proc_create() to make sure that ->proc_fops be setup before gluing PDE to main tree. Signed-off-by: Wang Chen <wangchen@cn.fujitsu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 46ecf0b commit 25296d5

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

‎net/core/pktgen.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3570,14 +3570,14 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
35703570
if (err)
35713571
goto out1;
35723572

3573-
pkt_dev->entry = create_proc_entry(ifname, 0600, pg_proc_dir);
3573+
pkt_dev->entry = proc_create(ifname, 0600,
3574+
pg_proc_dir, &pktgen_if_fops);
35743575
if (!pkt_dev->entry) {
35753576
printk(KERN_ERR "pktgen: cannot create %s/%s procfs entry.\n",
35763577
PG_PROC_DIR, ifname);
35773578
err = -EINVAL;
35783579
goto out2;
35793580
}
3580-
pkt_dev->entry->proc_fops = &pktgen_if_fops;
35813581
pkt_dev->entry->data = pkt_dev;
35823582
#ifdef CONFIG_XFRM
35833583
pkt_dev->ipsmode = XFRM_MODE_TRANSPORT;
@@ -3628,7 +3628,7 @@ static int __init pktgen_create_thread(int cpu)
36283628
kthread_bind(p, cpu);
36293629
t->tsk = p;
36303630

3631-
pe = create_proc_entry(t->tsk->comm, 0600, pg_proc_dir);
3631+
pe = proc_create(t->tsk->comm, 0600, pg_proc_dir, &pktgen_thread_fops);
36323632
if (!pe) {
36333633
printk(KERN_ERR "pktgen: cannot create %s/%s procfs entry.\n",
36343634
PG_PROC_DIR, t->tsk->comm);
@@ -3638,7 +3638,6 @@ static int __init pktgen_create_thread(int cpu)
36383638
return -EINVAL;
36393639
}
36403640

3641-
pe->proc_fops = &pktgen_thread_fops;
36423641
pe->data = t;
36433642

36443643
wake_up_process(p);
@@ -3709,15 +3708,14 @@ static int __init pg_init(void)
37093708
return -ENODEV;
37103709
pg_proc_dir->owner = THIS_MODULE;
37113710

3712-
pe = create_proc_entry(PGCTRL, 0600, pg_proc_dir);
3711+
pe = proc_create(PGCTRL, 0600, pg_proc_dir, &pktgen_fops);
37133712
if (pe == NULL) {
37143713
printk(KERN_ERR "pktgen: ERROR: cannot create %s "
37153714
"procfs entry.\n", PGCTRL);
37163715
proc_net_remove(&init_net, PG_PROC_DIR);
37173716
return -EINVAL;
37183717
}
37193718

3720-
pe->proc_fops = &pktgen_fops;
37213719
pe->data = NULL;
37223720

37233721
/* Register us to receive netdevice events */

0 commit comments

Comments
 (0)