mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
l2tp: take reference on sessions being dumped
Take a reference on the sessions returned by l2tp_session_find_nth() (and rename it l2tp_session_get_nth() to reflect this change), so that caller is assured that the session isn't going to disappear while processing it. For procfs and debugfs handlers, the session is held in the .start() callback and dropped in .show(). Given that pppol2tp_seq_session_show() dereferences the associated PPPoL2TP socket and that l2tp_dfs_seq_session_show() might call pppol2tp_show(), we also need to call the session's .ref() callback to prevent the socket from going away from under us. Fixes:fd558d186d
("l2tp: Split pppol2tp patch into separate l2tp and ppp parts") Fixes:0ad6614048
("l2tp: Add debugfs files for dumping l2tp debug info") Fixes:309795f4be
("l2tp: Add netlink control API for L2TP") Signed-off-by: Guillaume Nault <g.nault@alphalink.fr> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
0b9aefea86
commit
e08293a4cc
5 changed files with 27 additions and 11 deletions
|
@ -53,7 +53,7 @@ static void l2tp_dfs_next_tunnel(struct l2tp_dfs_seq_data *pd)
|
|||
|
||||
static void l2tp_dfs_next_session(struct l2tp_dfs_seq_data *pd)
|
||||
{
|
||||
pd->session = l2tp_session_find_nth(pd->tunnel, pd->session_idx);
|
||||
pd->session = l2tp_session_get_nth(pd->tunnel, pd->session_idx, true);
|
||||
pd->session_idx++;
|
||||
|
||||
if (pd->session == NULL) {
|
||||
|
@ -238,10 +238,14 @@ static int l2tp_dfs_seq_show(struct seq_file *m, void *v)
|
|||
}
|
||||
|
||||
/* Show the tunnel or session context */
|
||||
if (pd->session == NULL)
|
||||
if (!pd->session) {
|
||||
l2tp_dfs_seq_tunnel_show(m, pd->tunnel);
|
||||
else
|
||||
} else {
|
||||
l2tp_dfs_seq_session_show(m, pd->session);
|
||||
if (pd->session->deref)
|
||||
pd->session->deref(pd->session);
|
||||
l2tp_session_dec_refcount(pd->session);
|
||||
}
|
||||
|
||||
out:
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue