aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMonam Agarwal <monamagarwal123@gmail.com>2014-03-23 14:32:32 -0400
committerDavid S. Miller <davem@davemloft.net>2014-03-27 00:18:09 -0400
commitc956674b7c89e7992a09df309a9f226f02733421 (patch)
tree0763a326457ca49fafa6c4fb84ee3517bb1efeb1
parent8800a244fa1ab75192cf65ecf8e3ca3ec1420b1b (diff)
drivers/net: Use RCU_INIT_POINTER(x, NULL) in tun.c
This patch replaces rcu_assign_pointer(x, NULL) with RCU_INIT_POINTER(x, NULL) The rcu_assign_pointer() ensures that the initialization of a structure is carried out before storing a pointer to that structure. And in the case of the NULL pointer, there is no structure to initialize. So, rcu_assign_pointer(p, NULL) can be safely converted to RCU_INIT_POINTER(p, NULL) Signed-off-by: Monam Agarwal <monamagarwal123@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/tun.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 26f8635b027d..ee328ba101e7 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -452,7 +452,7 @@ static void __tun_detach(struct tun_file *tfile, bool clean)
452 452
453 --tun->numqueues; 453 --tun->numqueues;
454 if (clean) { 454 if (clean) {
455 rcu_assign_pointer(tfile->tun, NULL); 455 RCU_INIT_POINTER(tfile->tun, NULL);
456 sock_put(&tfile->sk); 456 sock_put(&tfile->sk);
457 } else 457 } else
458 tun_disable_queue(tun, tfile); 458 tun_disable_queue(tun, tfile);
@@ -499,12 +499,12 @@ static void tun_detach_all(struct net_device *dev)
499 tfile = rtnl_dereference(tun->tfiles[i]); 499 tfile = rtnl_dereference(tun->tfiles[i]);
500 BUG_ON(!tfile); 500 BUG_ON(!tfile);
501 wake_up_all(&tfile->wq.wait); 501 wake_up_all(&tfile->wq.wait);
502 rcu_assign_pointer(tfile->tun, NULL); 502 RCU_INIT_POINTER(tfile->tun, NULL);
503 --tun->numqueues; 503 --tun->numqueues;
504 } 504 }
505 list_for_each_entry(tfile, &tun->disabled, next) { 505 list_for_each_entry(tfile, &tun->disabled, next) {
506 wake_up_all(&tfile->wq.wait); 506 wake_up_all(&tfile->wq.wait);
507 rcu_assign_pointer(tfile->tun, NULL); 507 RCU_INIT_POINTER(tfile->tun, NULL);
508 } 508 }
509 BUG_ON(tun->numqueues != 0); 509 BUG_ON(tun->numqueues != 0);
510 510
@@ -2194,7 +2194,7 @@ static int tun_chr_open(struct inode *inode, struct file * file)
2194 &tun_proto); 2194 &tun_proto);
2195 if (!tfile) 2195 if (!tfile)
2196 return -ENOMEM; 2196 return -ENOMEM;
2197 rcu_assign_pointer(tfile->tun, NULL); 2197 RCU_INIT_POINTER(tfile->tun, NULL);
2198 tfile->net = get_net(current->nsproxy->net_ns); 2198 tfile->net = get_net(current->nsproxy->net_ns);
2199 tfile->flags = 0; 2199 tfile->flags = 0;
2200 tfile->ifindex = 0; 2200 tfile->ifindex = 0;