Declare the seq_operations and the size of the iterator state and let
procfs open and free the seq_file. ->proc_open() only fills in the table
now. Reading /proc/net/xt_recent/<table> then no longer holds up the
removal of the table.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
net/netfilter/xt_recent.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c
index 11acb9a50d4b..b771cc463aab 100644
--- a/net/netfilter/xt_recent.c
+++ b/net/netfilter/xt_recent.c
@@ -546,11 +546,7 @@ static const struct seq_operations recent_seq_ops = {
static int recent_seq_open(struct inode *inode, struct file *file)
{
- struct recent_iter_state *st;
-
- st = __seq_open_private(file, &recent_seq_ops, sizeof(*st));
- if (st == NULL)
- return -ENOMEM;
+ struct recent_iter_state *st = ((struct seq_file *)file->private_data)->private;
st->table = pde_data(inode);
return 0;@@ -626,11 +622,10 @@ recent_mt_proc_write(struct file *file, const char __user *input,
}
static const struct proc_ops recent_mt_proc_ops = {
+ .proc_seq_ops = &recent_seq_ops,
+ .proc_state_size = sizeof(struct recent_iter_state),
.proc_open = recent_seq_open,
- .proc_read = seq_read,
.proc_write = recent_mt_proc_write,
- .proc_release = seq_release_private,
- .proc_lseek = seq_lseek,
};
static int __net_init recent_proc_net_init(struct net *net)
--
2.53.0