Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 35901603 authored by Tomas Hozza's avatar Tomas Hozza Committed by Greg Kroah-Hartman
Browse files

tools: hv: Check return value of setsockopt call



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: default avatarTomas Hozza <thozza@redhat.com>
Acked-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 98b80d89
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -1457,7 +1457,13 @@ int main(void)
		exit(EXIT_FAILURE);
	}
	nl_group = CN_KVP_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.
	 */