Skip to content

Commit

Permalink
net/rds: Check laddr_check before calling it
Browse files Browse the repository at this point in the history
In rds_bind(), laddr_check is called without checking if it is NULL or
not.  And rs_transport should be reset if rds_add_bound() fails.

Fixes: c5c1a03 ("net/rds: An rds_sock is added too early to the hash table")
Reported-by: [email protected]
Signed-off-by: Ka-Cheong Poon <[email protected]>
Acked-by: Santosh Shilimkar <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
kcp-git authored and davem330 committed Sep 27, 2019
1 parent 4e1e83b commit 0573343
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion net/rds/bind.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
*/
if (rs->rs_transport) {
trans = rs->rs_transport;
if (trans->laddr_check(sock_net(sock->sk),
if (!trans->laddr_check ||
trans->laddr_check(sock_net(sock->sk),
binding_addr, scope_id) != 0) {
ret = -ENOPROTOOPT;
goto out;
Expand All @@ -263,6 +264,8 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)

sock_set_flag(sk, SOCK_RCU_FREE);
ret = rds_add_bound(rs, binding_addr, &port, scope_id);
if (ret)
rs->rs_transport = NULL;

out:
release_sock(sk);
Expand Down

0 comments on commit 0573343

Please sign in to comment.