Commit 39deb2c7 authored by Zhi Yong Wu's avatar Zhi Yong Wu Committed by David S. Miller

vxlan: silence one build warning

drivers/net/vxlan.c: In function ‘vxlan_sock_add’:
drivers/net/vxlan.c:2298:11: warning: ‘sock’ may be used uninitialized in this function [-Wmaybe-uninitialized]
drivers/net/vxlan.c:2275:17: note: ‘sock’ was declared here
  LD      drivers/net/built-in.o
Signed-off-by: default avatarZhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: default avatarStephen Hemminger <stephen@networkplumber.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent daba287b
...@@ -2180,7 +2180,7 @@ static void vxlan_del_work(struct work_struct *work) ...@@ -2180,7 +2180,7 @@ static void vxlan_del_work(struct work_struct *work)
* could be used for both IPv4 and IPv6 communications, but * could be used for both IPv4 and IPv6 communications, but
* users may set bindv6only=1. * users may set bindv6only=1.
*/ */
static int create_v6_sock(struct net *net, __be16 port, struct socket **psock) static struct socket *create_v6_sock(struct net *net, __be16 port)
{ {
struct sock *sk; struct sock *sk;
struct socket *sock; struct socket *sock;
...@@ -2193,7 +2193,7 @@ static int create_v6_sock(struct net *net, __be16 port, struct socket **psock) ...@@ -2193,7 +2193,7 @@ static int create_v6_sock(struct net *net, __be16 port, struct socket **psock)
rc = sock_create_kern(AF_INET6, SOCK_DGRAM, IPPROTO_UDP, &sock); rc = sock_create_kern(AF_INET6, SOCK_DGRAM, IPPROTO_UDP, &sock);
if (rc < 0) { if (rc < 0) {
pr_debug("UDPv6 socket create failed\n"); pr_debug("UDPv6 socket create failed\n");
return rc; return ERR_PTR(rc);
} }
/* Put in proper namespace */ /* Put in proper namespace */
...@@ -2208,28 +2208,27 @@ static int create_v6_sock(struct net *net, __be16 port, struct socket **psock) ...@@ -2208,28 +2208,27 @@ static int create_v6_sock(struct net *net, __be16 port, struct socket **psock)
pr_debug("bind for UDPv6 socket %pI6:%u (%d)\n", pr_debug("bind for UDPv6 socket %pI6:%u (%d)\n",
&vxlan_addr.sin6_addr, ntohs(vxlan_addr.sin6_port), rc); &vxlan_addr.sin6_addr, ntohs(vxlan_addr.sin6_port), rc);
sk_release_kernel(sk); sk_release_kernel(sk);
return rc; return ERR_PTR(rc);
} }
/* At this point, IPv6 module should have been loaded in /* At this point, IPv6 module should have been loaded in
* sock_create_kern(). * sock_create_kern().
*/ */
BUG_ON(!ipv6_stub); BUG_ON(!ipv6_stub);
*psock = sock;
/* Disable multicast loopback */ /* Disable multicast loopback */
inet_sk(sk)->mc_loop = 0; inet_sk(sk)->mc_loop = 0;
return 0; return sock;
} }
#else #else
static int create_v6_sock(struct net *net, __be16 port, struct socket **psock) static struct socket *create_v6_sock(struct net *net, __be16 port)
{ {
return -EPFNOSUPPORT; return ERR_PTR(-EPFNOSUPPORT);
} }
#endif #endif
static int create_v4_sock(struct net *net, __be16 port, struct socket **psock) static struct socket *create_v4_sock(struct net *net, __be16 port)
{ {
struct sock *sk; struct sock *sk;
struct socket *sock; struct socket *sock;
...@@ -2244,7 +2243,7 @@ static int create_v4_sock(struct net *net, __be16 port, struct socket **psock) ...@@ -2244,7 +2243,7 @@ static int create_v4_sock(struct net *net, __be16 port, struct socket **psock)
rc = sock_create_kern(AF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock); rc = sock_create_kern(AF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock);
if (rc < 0) { if (rc < 0) {
pr_debug("UDP socket create failed\n"); pr_debug("UDP socket create failed\n");
return rc; return ERR_PTR(rc);
} }
/* Put in proper namespace */ /* Put in proper namespace */
...@@ -2257,13 +2256,12 @@ static int create_v4_sock(struct net *net, __be16 port, struct socket **psock) ...@@ -2257,13 +2256,12 @@ static int create_v4_sock(struct net *net, __be16 port, struct socket **psock)
pr_debug("bind for UDP socket %pI4:%u (%d)\n", pr_debug("bind for UDP socket %pI4:%u (%d)\n",
&vxlan_addr.sin_addr, ntohs(vxlan_addr.sin_port), rc); &vxlan_addr.sin_addr, ntohs(vxlan_addr.sin_port), rc);
sk_release_kernel(sk); sk_release_kernel(sk);
return rc; return ERR_PTR(rc);
} }
*psock = sock;
/* Disable multicast loopback */ /* Disable multicast loopback */
inet_sk(sk)->mc_loop = 0; inet_sk(sk)->mc_loop = 0;
return 0; return sock;
} }
/* Create new listen socket if needed */ /* Create new listen socket if needed */
...@@ -2274,7 +2272,6 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port, ...@@ -2274,7 +2272,6 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port,
struct vxlan_sock *vs; struct vxlan_sock *vs;
struct socket *sock; struct socket *sock;
struct sock *sk; struct sock *sk;
int rc = 0;
unsigned int h; unsigned int h;
vs = kmalloc(sizeof(*vs), GFP_KERNEL); vs = kmalloc(sizeof(*vs), GFP_KERNEL);
...@@ -2287,12 +2284,12 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port, ...@@ -2287,12 +2284,12 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, __be16 port,
INIT_WORK(&vs->del_work, vxlan_del_work); INIT_WORK(&vs->del_work, vxlan_del_work);
if (ipv6) if (ipv6)
rc = create_v6_sock(net, port, &sock); sock = create_v6_sock(net, port);
else else
rc = create_v4_sock(net, port, &sock); sock = create_v4_sock(net, port);
if (rc < 0) { if (IS_ERR(sock)) {
kfree(vs); kfree(vs);
return ERR_PTR(rc); return ERR_PTR(PTR_ERR(sock));
} }
vs->sock = sock; vs->sock = sock;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment