tools: hv: Check return value of setsockopt call
authorTomas Hozza <thozza@redhat.com>
Thu, 27 Jun 2013 11:52:48 +0000 (13:52 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Jul 2013 23:40:41 +0000 (16:40 -0700)
Check return value of setsockopt call and if it fails print error to the
system log and exit with non-zero value.

Signed-off-by: Tomas Hozza <thozza@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/hv/hv_vss_daemon.c

index 5febe3542f796b4559fc5a7280217502daea62f3..826d499dc3542ade376e728ab86cfe622dab60a5 100644 (file)
@@ -173,7 +173,11 @@ int main(void)
                exit(EXIT_FAILURE);
        }
        nl_group = CN_VSS_IDX;
-       setsockopt(fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &nl_group, sizeof(nl_group));
+       if (setsockopt(fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &nl_group, sizeof(nl_group)) < 0) {
+               syslog(LOG_ERR, "setsockopt failed; error:%d %s", errno, strerror(errno));
+               close(fd);
+               exit(EXIT_FAILURE);
+       }
        /*
         * Register ourselves with the kernel.
         */