diff mbox

odp_packet_socket.c: Fix call to bind with negative fd

Message ID 1413578439-22781-1-git-send-email-mike.holmes@linaro.org
State Accepted
Commit 469e2764add195a133a199922d4c7769e5bb7a03
Headers show

Commit Message

Mike Holmes Oct. 17, 2014, 8:40 p.m. UTC
Failure from the socket create call should propagate up and not be passed
into bind.

Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 platform/linux-generic/odp_packet_socket.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Maxim Uvarov Oct. 21, 2014, 12:14 p.m. UTC | #1
Merged!
Maxim.

On 10/18/2014 12:40 AM, Mike Holmes wrote:
> Failure from the socket create call should propagate up and not be passed
> into bind.
>
> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
> ---
>   platform/linux-generic/odp_packet_socket.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/platform/linux-generic/odp_packet_socket.c b/platform/linux-generic/odp_packet_socket.c
> index da9b5a0..0492d1e 100644
> --- a/platform/linux-generic/odp_packet_socket.c
> +++ b/platform/linux-generic/odp_packet_socket.c
> @@ -829,6 +829,8 @@ int setup_pkt_sock_mmap(pkt_sock_mmap_t *const pkt_sock, const char *netdev,
>   
>   	pkt_sock->pool = pool;
>   	pkt_sock->sockfd = mmap_pkt_socket();
> +	if (pkt_sock->sockfd == -1)
> +		return -1;
>   
>   	ret = mmap_bind_sock(pkt_sock, netdev);
>   	if (ret != 0)
diff mbox

Patch

diff --git a/platform/linux-generic/odp_packet_socket.c b/platform/linux-generic/odp_packet_socket.c
index da9b5a0..0492d1e 100644
--- a/platform/linux-generic/odp_packet_socket.c
+++ b/platform/linux-generic/odp_packet_socket.c
@@ -829,6 +829,8 @@  int setup_pkt_sock_mmap(pkt_sock_mmap_t *const pkt_sock, const char *netdev,
 
 	pkt_sock->pool = pool;
 	pkt_sock->sockfd = mmap_pkt_socket();
+	if (pkt_sock->sockfd == -1)
+		return -1;
 
 	ret = mmap_bind_sock(pkt_sock, netdev);
 	if (ret != 0)