make sock_alloc_file() do sock_release() on failures
This changes calling conventions (and simplifies the hell out the callers). New rules: once struct socket had been passed to sock_alloc_file(), it's been consumed either by struct file or by sock_release() done by sock_alloc_file(). Either way the caller should not do sock_release() after that point. Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
@@ -1629,7 +1629,6 @@ static struct file *kcm_clone(struct socket *osock)
|
||||
{
|
||||
struct socket *newsock;
|
||||
struct sock *newsk;
|
||||
struct file *file;
|
||||
|
||||
newsock = sock_alloc();
|
||||
if (!newsock)
|
||||
@@ -1649,11 +1648,7 @@ static struct file *kcm_clone(struct socket *osock)
|
||||
sock_init_data(newsock, newsk);
|
||||
init_kcm_sock(kcm_sk(newsk), kcm_sk(osock->sk)->mux);
|
||||
|
||||
file = sock_alloc_file(newsock, 0, osock->sk->sk_prot_creator->name);
|
||||
if (IS_ERR(file))
|
||||
sock_release(newsock);
|
||||
|
||||
return file;
|
||||
return sock_alloc_file(newsock, 0, osock->sk->sk_prot_creator->name);
|
||||
}
|
||||
|
||||
static int kcm_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
|
||||
|
||||
Reference in New Issue
Block a user