Skip to content

Commit 8fb8e9e

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
Pull rdma fix from Doug Ledford: "Much calmer week this week. Just one patch queued up: The way the siw driver was locking around the traversal of the list of ipv6 addresses on a device was causing a scheduling while atomic issue. Bernard straightened it out by using the rtnl_lock" * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: RDMA/siw: Fix IPv6 addr_list locking
2 parents fbcb0b4 + 531a64e commit 8fb8e9e

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

‎drivers/infiniband/sw/siw/siw_cm.c‎

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,6 +1962,10 @@ int siw_create_listen(struct iw_cm_id *id, int backlog)
19621962
struct sockaddr_in s_laddr, *s_raddr;
19631963
const struct in_ifaddr *ifa;
19641964

1965+
if (!in_dev) {
1966+
rv = -ENODEV;
1967+
goto out;
1968+
}
19651969
memcpy(&s_laddr, &id->local_addr, sizeof(s_laddr));
19661970
s_raddr = (struct sockaddr_in *)&id->remote_addr;
19671971

@@ -1991,22 +1995,27 @@ int siw_create_listen(struct iw_cm_id *id, int backlog)
19911995
struct sockaddr_in6 *s_laddr = &to_sockaddr_in6(id->local_addr),
19921996
*s_raddr = &to_sockaddr_in6(id->remote_addr);
19931997

1998+
if (!in6_dev) {
1999+
rv = -ENODEV;
2000+
goto out;
2001+
}
19942002
siw_dbg(id->device,
19952003
"laddr %pI6:%d, raddr %pI6:%d\n",
19962004
&s_laddr->sin6_addr, ntohs(s_laddr->sin6_port),
19972005
&s_raddr->sin6_addr, ntohs(s_raddr->sin6_port));
19982006

1999-
read_lock_bh(&in6_dev->lock);
2007+
rtnl_lock();
20002008
list_for_each_entry(ifp, &in6_dev->addr_list, if_list) {
2001-
struct sockaddr_in6 bind_addr;
2002-
2009+
if (ifp->flags & (IFA_F_TENTATIVE | IFA_F_DEPRECATED))
2010+
continue;
20032011
if (ipv6_addr_any(&s_laddr->sin6_addr) ||
20042012
ipv6_addr_equal(&s_laddr->sin6_addr, &ifp->addr)) {
2005-
bind_addr.sin6_family = AF_INET6;
2006-
bind_addr.sin6_port = s_laddr->sin6_port;
2007-
bind_addr.sin6_flowinfo = 0;
2008-
bind_addr.sin6_addr = ifp->addr;
2009-
bind_addr.sin6_scope_id = dev->ifindex;
2013+
struct sockaddr_in6 bind_addr = {
2014+
.sin6_family = AF_INET6,
2015+
.sin6_port = s_laddr->sin6_port,
2016+
.sin6_flowinfo = 0,
2017+
.sin6_addr = ifp->addr,
2018+
.sin6_scope_id = dev->ifindex };
20102019

20112020
rv = siw_listen_address(id, backlog,
20122021
(struct sockaddr *)&bind_addr,
@@ -2015,12 +2024,12 @@ int siw_create_listen(struct iw_cm_id *id, int backlog)
20152024
listeners++;
20162025
}
20172026
}
2018-
read_unlock_bh(&in6_dev->lock);
2019-
2027+
rtnl_unlock();
20202028
in6_dev_put(in6_dev);
20212029
} else {
2022-
return -EAFNOSUPPORT;
2030+
rv = -EAFNOSUPPORT;
20232031
}
2032+
out:
20242033
if (listeners)
20252034
rv = 0;
20262035
else if (!rv)

0 commit comments

Comments
 (0)