aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/pppol2tp.c
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2009-01-27 00:10:08 -0500
committerDavid S. Miller <davem@davemloft.net>2009-01-27 00:10:08 -0500
commitcbec6605cf0fd5080f03eb787c95c1ecd660421f (patch)
tree7e06a8370b12a0edd97f28a73a60d4532cea43d5 /drivers/net/pppol2tp.c
parent9a3b7a42bb2919a6282a96a5f4abe0f9be36c4b3 (diff)
pppol2tp: stop using proc internals
PDE_NET usage in driver code is a sign and, indeed, switching to seq_open_net/seq_release_net saves code and fixes bogus things, like user triggerabble BUG_ON(!net) after maybe_get_net, and NULLifying ->private. Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/pppol2tp.c')
-rw-r--r--drivers/net/pppol2tp.c48
1 files changed, 5 insertions, 43 deletions
diff --git a/drivers/net/pppol2tp.c b/drivers/net/pppol2tp.c
index 056e22a784b8..15f4a43a6890 100644
--- a/drivers/net/pppol2tp.c
+++ b/drivers/net/pppol2tp.c
@@ -2371,7 +2371,7 @@ end:
2371#include <linux/seq_file.h> 2371#include <linux/seq_file.h>
2372 2372
2373struct pppol2tp_seq_data { 2373struct pppol2tp_seq_data {
2374 struct net *seq_net; /* net of inode */ 2374 struct seq_net_private p;
2375 struct pppol2tp_tunnel *tunnel; /* current tunnel */ 2375 struct pppol2tp_tunnel *tunnel; /* current tunnel */
2376 struct pppol2tp_session *session; /* NULL means get first session in tunnel */ 2376 struct pppol2tp_session *session; /* NULL means get first session in tunnel */
2377}; 2377};
@@ -2436,7 +2436,7 @@ static void *pppol2tp_seq_start(struct seq_file *m, loff_t *offs)
2436 2436
2437 BUG_ON(m->private == NULL); 2437 BUG_ON(m->private == NULL);
2438 pd = m->private; 2438 pd = m->private;
2439 pn = pppol2tp_pernet(pd->seq_net); 2439 pn = pppol2tp_pernet(seq_file_net(m));
2440 2440
2441 if (pd->tunnel == NULL) { 2441 if (pd->tunnel == NULL) {
2442 if (!list_empty(&pn->pppol2tp_tunnel_list)) 2442 if (!list_empty(&pn->pppol2tp_tunnel_list))
@@ -2558,46 +2558,8 @@ static const struct seq_operations pppol2tp_seq_ops = {
2558 */ 2558 */
2559static int pppol2tp_proc_open(struct inode *inode, struct file *file) 2559static int pppol2tp_proc_open(struct inode *inode, struct file *file)
2560{ 2560{
2561 struct seq_file *m; 2561 return seq_open_net(inode, file, &pppol2tp_seq_ops,
2562 struct pppol2tp_seq_data *pd; 2562 sizeof(struct pppol2tp_seq_data));
2563 struct net *net;
2564 int ret = 0;
2565
2566 ret = seq_open(file, &pppol2tp_seq_ops);
2567 if (ret < 0)
2568 goto out;
2569
2570 m = file->private_data;
2571
2572 /* Allocate and fill our proc_data for access later */
2573 ret = -ENOMEM;
2574 m->private = kzalloc(sizeof(*pd), GFP_KERNEL);
2575 if (m->private == NULL)
2576 goto out;
2577
2578 pd = m->private;
2579 net = maybe_get_net(PDE_NET(PDE(inode)));
2580 BUG_ON(!net);
2581 pd->seq_net = net;
2582 return 0;
2583
2584out:
2585 return ret;
2586}
2587
2588/* Called when /proc file access completes.
2589 */
2590static int pppol2tp_proc_release(struct inode *inode, struct file *file)
2591{
2592 struct seq_file *m = (struct seq_file *)file->private_data;
2593 struct pppol2tp_seq_data *pd = m->private;
2594
2595 put_net(pd->seq_net);
2596
2597 kfree(m->private);
2598 m->private = NULL;
2599
2600 return seq_release(inode, file);
2601} 2563}
2602 2564
2603static const struct file_operations pppol2tp_proc_fops = { 2565static const struct file_operations pppol2tp_proc_fops = {
@@ -2605,7 +2567,7 @@ static const struct file_operations pppol2tp_proc_fops = {
2605 .open = pppol2tp_proc_open, 2567 .open = pppol2tp_proc_open,
2606 .read = seq_read, 2568 .read = seq_read,
2607 .llseek = seq_lseek, 2569 .llseek = seq_lseek,
2608 .release = pppol2tp_proc_release, 2570 .release = seq_release_net,
2609}; 2571};
2610 2572
2611#endif /* CONFIG_PROC_FS */ 2573#endif /* CONFIG_PROC_FS */