diff options
author | Dmitry Baryshkov <dbaryshkov@gmail.com> | 2009-08-06 22:58:42 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-08-13 00:54:50 -0400 |
commit | 74eda55db4335383ccdd1fb51a7b014202f89366 (patch) | |
tree | 4671a186d38196577afd5fd8d7192b40ac3e9723 /net/ieee802154 | |
parent | 8e753dd0a82bd266256c20a20b98dfa48f98d21e (diff) |
af_ieee802154: minor cleanup in dgram_bind
1) fix ro->bound protection by socket lock
2) make ro->bound bit instead of int
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ieee802154')
-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: |