static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{
	struct sock *sk = sock->sk;
	struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr;
	char *sun_path = sunaddr->sun_path;
	int err;
	unsigned int hash;
	struct unix_address *addr;

	if (addr_len < offsetofend(struct sockaddr_un, sun_family) ||
	    sunaddr->sun_family != AF_UNIX)
		return -EINVAL;

	if (addr_len == sizeof(short))
		return unix_autobind(sock);

	err = unix_mkname(sunaddr, addr_len, &hash);
	if (err < 0)
		return err;
	addr_len = err;
	addr = kmalloc(sizeof(*addr)+addr_len, GFP_KERNEL);
	if (!addr)
		return -ENOMEM;

	memcpy(addr->name, sunaddr, addr_len);
	addr->len = addr_len;
	addr->hash = hash ^ sk->sk_type;
	refcount_set(&addr->refcnt, 1);

	if (sun_path[0])
		err = unix_bind_bsd(sk, addr);
	else
		err = unix_bind_abstract(sk, addr);
	if (err)
		unix_release_addr(addr);
	return err == -EEXIST ? -EADDRINUSE : err;
}
static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
{
	struct sock *sk = sock->sk;
	struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr;
	char *sun_path = sunaddr->sun_path;
	int err;
	unsigned int hash;
	struct unix_address *addr;

	if (addr_len < offsetofend(struct sockaddr_un, sun_family) ||
	    sunaddr->sun_family != AF_UNIX)
		return -EINVAL;

	if (addr_len == sizeof(short))
		return unix_autobind(sock);

	err = unix_mkname(sunaddr, addr_len, &hash);
	if (err < 0)
		return err;
	addr_len = err;
	addr = kmalloc(sizeof(*addr)+addr_len, GFP_KERNEL);
	if (!addr)
		return -ENOMEM;

	memcpy(addr->name, sunaddr, addr_len);
	addr->len = addr_len;
	addr->hash = hash ^ sk->sk_type;
	refcount_set(&addr->refcnt, 1);

	if (sun_path[0])
		err = unix_bind_bsd(sk, addr);
	else
		err = unix_bind_abstract(sk, addr);
	if (err)
		unix_release_addr(addr);
	return err == -EEXIST ? -EADDRINUSE : err;
}