diff options
Diffstat (limited to 'net/ieee802154/dgram.c')
-rw-r--r-- | net/ieee802154/dgram.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/net/ieee802154/dgram.c b/net/ieee802154/dgram.c index d1da6c619c7d..25018a9a53aa 100644 --- a/net/ieee802154/dgram.c +++ b/net/ieee802154/dgram.c | |||
@@ -40,9 +40,10 @@ static DEFINE_RWLOCK(dgram_lock); | |||
40 | struct dgram_sock { | 40 | struct dgram_sock { |
41 | struct sock sk; | 41 | struct sock sk; |
42 | 42 | ||
43 | int bound; | ||
44 | struct ieee802154_addr src_addr; | 43 | struct ieee802154_addr src_addr; |
45 | struct ieee802154_addr dst_addr; | 44 | struct ieee802154_addr dst_addr; |
45 | |||
46 | unsigned bound:1; | ||
46 | }; | 47 | }; |
47 | 48 | ||
48 | static inline struct dgram_sock *dgram_sk(const struct sock *sk) | 49 | static inline struct dgram_sock *dgram_sk(const struct sock *sk) |
@@ -86,18 +87,18 @@ static int dgram_bind(struct sock *sk, struct sockaddr *uaddr, int len) | |||
86 | { | 87 | { |
87 | struct sockaddr_ieee802154 *addr = (struct sockaddr_ieee802154 *)uaddr; | 88 | struct sockaddr_ieee802154 *addr = (struct sockaddr_ieee802154 *)uaddr; |
88 | struct dgram_sock *ro = dgram_sk(sk); | 89 | struct dgram_sock *ro = dgram_sk(sk); |
89 | int err = 0; | 90 | int err = -EINVAL; |
90 | struct net_device *dev; | 91 | struct net_device *dev; |
91 | 92 | ||
93 | lock_sock(sk); | ||
94 | |||
92 | ro->bound = 0; | 95 | ro->bound = 0; |
93 | 96 | ||
94 | if (len < sizeof(*addr)) | 97 | if (len < sizeof(*addr)) |
95 | return -EINVAL; | 98 | goto out; |
96 | 99 | ||
97 | if (addr->family != AF_IEEE802154) | 100 | if (addr->family != AF_IEEE802154) |
98 | return -EINVAL; | 101 | goto out; |
99 | |||
100 | lock_sock(sk); | ||
101 | 102 | ||
102 | dev = ieee802154_get_dev(sock_net(sk), &addr->addr); | 103 | dev = ieee802154_get_dev(sock_net(sk), &addr->addr); |
103 | if (!dev) { | 104 | if (!dev) { |
@@ -113,6 +114,7 @@ static int dgram_bind(struct sock *sk, struct sockaddr *uaddr, int len) | |||
113 | memcpy(&ro->src_addr, &addr->addr, sizeof(struct ieee802154_addr)); | 114 | memcpy(&ro->src_addr, &addr->addr, sizeof(struct ieee802154_addr)); |
114 | 115 | ||
115 | ro->bound = 1; | 116 | ro->bound = 1; |
117 | err = 0; | ||
116 | out_put: | 118 | out_put: |
117 | dev_put(dev); | 119 | dev_put(dev); |
118 | out: | 120 | out: |