Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 9435
b: refs/heads/master
c: a79af59
h: refs/heads/master
i:
  9433: de7396f
  9431: 166f2e1
v: v3
  • Loading branch information
Frank Filz authored and David S. Miller committed Sep 27, 2005
1 parent 61458e9 commit 6b15d0d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9356b8fc07dc126cd91d2b12f314d760ab48996e
refs/heads/master: a79af59efd20990473d579b1d8d70bb120f0920c
20 changes: 12 additions & 8 deletions trunk/net/core/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,16 +660,20 @@ struct sock *sk_alloc(int family, unsigned int __nocast priority,
sock_lock_init(sk);
}

if (security_sk_alloc(sk, family, priority)) {
if (slab != NULL)
kmem_cache_free(slab, sk);
else
kfree(sk);
sk = NULL;
} else
__module_get(prot->owner);
if (security_sk_alloc(sk, family, priority))
goto out_free;

if (!try_module_get(prot->owner))
goto out_free;
}
return sk;

out_free:
if (slab != NULL)
kmem_cache_free(slab, sk);
else
kfree(sk);
return NULL;
}

void sk_free(struct sock *sk)
Expand Down
13 changes: 8 additions & 5 deletions trunk/net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1145,8 +1145,11 @@ static int __sock_create(int family, int type, int protocol, struct socket **res
if (!try_module_get(net_families[family]->owner))
goto out_release;

if ((err = net_families[family]->create(sock, protocol)) < 0)
if ((err = net_families[family]->create(sock, protocol)) < 0) {
sock->ops = NULL;
goto out_module_put;
}

/*
* Now to bump the refcnt of the [loadable] module that owns this
* socket at sock_release time we decrement its refcnt.
Expand Down Expand Up @@ -1360,16 +1363,16 @@ asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr, int _
newsock->type = sock->type;
newsock->ops = sock->ops;

err = security_socket_accept(sock, newsock);
if (err)
goto out_release;

/*
* We don't need try_module_get here, as the listening socket (sock)
* has the protocol module (sock->ops->owner) held.
*/
__module_get(newsock->ops->owner);

err = security_socket_accept(sock, newsock);
if (err)
goto out_release;

err = sock->ops->accept(sock, newsock, sock->file->f_flags);
if (err < 0)
goto out_release;
Expand Down

0 comments on commit 6b15d0d

Please sign in to comment.