summaryrefslogtreecommitdiffstats
path: root/net/sctp/socket.c
diff options
context:
space:
mode:
authorXin Long <lucien.xin@gmail.com>2016-04-14 15:35:35 +0800
committerDavid S. Miller <davem@davemloft.net>2016-04-15 17:29:37 -0400
commit53fa10369c45a51947f06e8b622d2fa2cc64fda1 (patch)
treed8a03375bdd9433670e8d16db957462a480c83fa /net/sctp/socket.c
parentb5e2f4e6998a2b999da8fa0290b692f0bd85c8b7 (diff)
downloadlinux-53fa10369c45a51947f06e8b622d2fa2cc64fda1.tar.bz2
sctp: fix some rhashtable functions using in sctp proc/diag
When rhashtable_walk_init return err, no release function should be called, and when rhashtable_walk_start return err, we should only invoke rhashtable_walk_exit to release the source. But now when sctp_transport_walk_start return err, we just call rhashtable_walk_stop/exit, and never care about if rhashtable_walk_init or start return err, which is so bad. We will fix it by calling rhashtable_walk_exit if rhashtable_walk_start return err in sctp_transport_walk_start, and if sctp_transport_walk_start return err, we do not need to call sctp_transport_walk_stop any more. For sctp proc, we will use 'iter->start_fail' to decide if we will call rhashtable_walk_stop/exit. Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/socket.c')
-rw-r--r--net/sctp/socket.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 5e5bc08d2b25..777d0324594a 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -4299,8 +4299,12 @@ int sctp_transport_walk_start(struct rhashtable_iter *iter)
return err;
err = rhashtable_walk_start(iter);
+ if (err && err != -EAGAIN) {
+ rhashtable_walk_exit(iter);
+ return err;
+ }
- return err == -EAGAIN ? 0 : err;
+ return 0;
}
void sctp_transport_walk_stop(struct rhashtable_iter *iter)
@@ -4389,11 +4393,12 @@ EXPORT_SYMBOL_GPL(sctp_transport_lookup_process);
int sctp_for_each_transport(int (*cb)(struct sctp_transport *, void *),
struct net *net, int pos, void *p) {
struct rhashtable_iter hti;
- int err = 0;
void *obj;
+ int err;
- if (sctp_transport_walk_start(&hti))
- goto out;
+ err = sctp_transport_walk_start(&hti);
+ if (err)
+ return err;
sctp_transport_get_idx(net, &hti, pos);
obj = sctp_transport_get_next(net, &hti);
@@ -4407,8 +4412,8 @@ int sctp_for_each_transport(int (*cb)(struct sctp_transport *, void *),
if (err)
break;
}
-out:
sctp_transport_walk_stop(&hti);
+
return err;
}
EXPORT_SYMBOL_GPL(sctp_for_each_transport);