[ovs-dev] [coverity 09/12] netdev-linux: Check return value of set_nonblocking().

Ethan Jackson ethan at nicira.com
Fri Feb 1 21:57:29 UTC 2013


Acked-by: Ethan Jackson <ethan at nicira.com>

On Thu, Jan 24, 2013 at 2:44 PM, Ben Pfaff <blp at nicira.com> wrote:
> It's unlikely to fail but checking it can't hurt.
>
> Found by Coverity.
>
> Signed-off-by: Ben Pfaff <blp at nicira.com>
> ---
>  lib/netdev-linux.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
> index 433d168..a1ddbe4 100644
> --- a/lib/netdev-linux.c
> +++ b/lib/netdev-linux.c
> @@ -4586,7 +4586,11 @@ af_packet_sock(void)
>      if (sock == INT_MIN) {
>          sock = socket(AF_PACKET, SOCK_RAW, 0);
>          if (sock >= 0) {
> -            set_nonblocking(sock);
> +            int error = set_nonblocking(sock);
> +            if (error) {
> +                close(sock);
> +                sock = -error;
> +            }
>          } else {
>              sock = -errno;
>              VLOG_ERR("failed to create packet socket: %s", strerror(errno));
> --
> 1.7.2.5
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev



More information about the dev mailing list