diff options
Diffstat (limited to 'net/atm/clip.c')
-rw-r--r-- | net/atm/clip.c | 42 |
1 files changed, 5 insertions, 37 deletions
diff --git a/net/atm/clip.c b/net/atm/clip.c index df7d218a6827..45e08620c8ca 100644 --- a/net/atm/clip.c +++ b/net/atm/clip.c | |||
@@ -903,6 +903,8 @@ static void *clip_seq_sub_iter(struct neigh_seq_state *_state, | |||
903 | 903 | ||
904 | static void *clip_seq_start(struct seq_file *seq, loff_t * pos) | 904 | static void *clip_seq_start(struct seq_file *seq, loff_t * pos) |
905 | { | 905 | { |
906 | struct clip_seq_state *state = seq->private; | ||
907 | state->ns.neigh_sub_iter = clip_seq_sub_iter; | ||
906 | return neigh_seq_start(seq, pos, &clip_tbl, NEIGH_SEQ_NEIGH_ONLY); | 908 | return neigh_seq_start(seq, pos, &clip_tbl, NEIGH_SEQ_NEIGH_ONLY); |
907 | } | 909 | } |
908 | 910 | ||
@@ -932,49 +934,15 @@ static const struct seq_operations arp_seq_ops = { | |||
932 | 934 | ||
933 | static int arp_seq_open(struct inode *inode, struct file *file) | 935 | static int arp_seq_open(struct inode *inode, struct file *file) |
934 | { | 936 | { |
935 | struct clip_seq_state *state; | 937 | return seq_open_net(inode, file, &arp_seq_ops, |
936 | struct seq_file *seq; | 938 | sizeof(struct clip_seq_state)); |
937 | int rc = -EAGAIN; | ||
938 | |||
939 | state = kzalloc(sizeof(*state), GFP_KERNEL); | ||
940 | if (!state) { | ||
941 | rc = -ENOMEM; | ||
942 | goto out_kfree; | ||
943 | } | ||
944 | state->ns.neigh_sub_iter = clip_seq_sub_iter; | ||
945 | |||
946 | rc = seq_open(file, &arp_seq_ops); | ||
947 | if (rc) | ||
948 | goto out_kfree; | ||
949 | |||
950 | seq = file->private_data; | ||
951 | seq->private = state; | ||
952 | state->ns.net = get_proc_net(inode); | ||
953 | if (!state->ns.net) { | ||
954 | seq_release_private(inode, file); | ||
955 | rc = -ENXIO; | ||
956 | } | ||
957 | out: | ||
958 | return rc; | ||
959 | |||
960 | out_kfree: | ||
961 | kfree(state); | ||
962 | goto out; | ||
963 | } | ||
964 | |||
965 | static int arp_seq_release(struct inode *inode, struct file *file) | ||
966 | { | ||
967 | struct seq_file *seq = file->private_data; | ||
968 | struct clip_seq_state *state = seq->private; | ||
969 | put_net(state->ns.net); | ||
970 | return seq_release_private(inode, file); | ||
971 | } | 939 | } |
972 | 940 | ||
973 | static const struct file_operations arp_seq_fops = { | 941 | static const struct file_operations arp_seq_fops = { |
974 | .open = arp_seq_open, | 942 | .open = arp_seq_open, |
975 | .read = seq_read, | 943 | .read = seq_read, |
976 | .llseek = seq_lseek, | 944 | .llseek = seq_lseek, |
977 | .release = arp_seq_release, | 945 | .release = seq_release_net, |
978 | .owner = THIS_MODULE | 946 | .owner = THIS_MODULE |
979 | }; | 947 | }; |
980 | #endif | 948 | #endif |