Skip to content

Commit

Permalink
af_ieee802154: minor cleanup in dgram_bind
Browse files Browse the repository at this point in the history
1) fix ro->bound protection by socket lock
2) make ro->bound bit instead of int

Signed-off-by: Dmitry Eremin-Solenikov <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
lumag authored and davem330 committed Aug 13, 2009
1 parent 8e753dd commit 74eda55
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions net/ieee802154/dgram.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand All @@ -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:
Expand Down

0 comments on commit 74eda55

Please sign in to comment.