summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDmitry Baryshkov <dbaryshkov@gmail.com>2009-08-07 02:58:42 +0000
committerDavid S. Miller <davem@davemloft.net>2009-08-12 21:54:50 -0700
commit74eda55db4335383ccdd1fb51a7b014202f89366 (patch)
tree4671a186d38196577afd5fd8d7192b40ac3e9723 /net
parent8e753dd0a82bd266256c20a20b98dfa48f98d21e (diff)
downloadkernel-crypto-74eda55db4335383ccdd1fb51a7b014202f89366.tar.gz
kernel-crypto-74eda55db4335383ccdd1fb51a7b014202f89366.tar.xz
kernel-crypto-74eda55db4335383ccdd1fb51a7b014202f89366.zip
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')
-rw-r--r--net/ieee802154/dgram.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/net/ieee802154/dgram.c b/net/ieee802154/dgram.c
index d1da6c619c7..25018a9a53a 100644
--- a/net/ieee802154/dgram.c
+++ b/net/ieee802154/dgram.c
@@ -40,9 +40,10 @@ static DEFINE_RWLOCK(dgram_lock);
struct dgram_sock {
struct sock sk;
- int bound;
struct ieee802154_addr src_addr;
struct ieee802154_addr dst_addr;
+
+ unsigned bound:1;
};
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)
{
struct sockaddr_ieee802154 *addr = (struct sockaddr_ieee802154 *)uaddr;
struct dgram_sock *ro = dgram_sk(sk);
- int err = 0;
+ int err = -EINVAL;
struct net_device *dev;
+ lock_sock(sk);
+
ro->bound = 0;
if (len < sizeof(*addr))
- return -EINVAL;
+ goto out;
if (addr->family != AF_IEEE802154)
- return -EINVAL;
-
- lock_sock(sk);
+ goto out;
dev = ieee802154_get_dev(sock_net(sk), &addr->addr);
if (!dev) {
@@ -113,6 +114,7 @@ static int dgram_bind(struct sock *sk, struct sockaddr *uaddr, int len)
memcpy(&ro->src_addr, &addr->addr, sizeof(struct ieee802154_addr));
ro->bound = 1;
+ err = 0;
out_put:
dev_put(dev);
out: