- tools: hv: Improve error logging in VSS daemon.
[opensuse:kernel-source.git] / patches.suse / msft-hv-0529-tools-hv-Check-return-value-of-setsockopt-call.patch
1 From: Tomas Hozza <thozza@redhat.com>
2 Date: Thu, 27 Jun 2013 13:52:48 +0200
3 Patch-mainline: v3.12-rc1
4 Subject: tools: hv: Check return value of setsockopt call
5 Git-commit: d12e14692448e9f256028f53926a9bd3c3091e11
6
7 Check return value of setsockopt call and if it fails print error to the
8 system log and exit with non-zero value.
9
10 Signed-off-by: Tomas Hozza <thozza@redhat.com>
11 Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
12 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
13 Acked-by: <ohering@suse.de>
14 ---
15  tools/hv/hv_vss_daemon.c | 6 +++++-
16  1 file changed, 5 insertions(+), 1 deletion(-)
17
18 diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
19 index 5febe35..826d499 100644
20 --- a/tools/hv/hv_vss_daemon.c
21 +++ b/tools/hv/hv_vss_daemon.c
22 @@ -173,7 +173,11 @@ int main(void)
23                 exit(EXIT_FAILURE);
24         }
25         nl_group = CN_VSS_IDX;
26 -       setsockopt(fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &nl_group, sizeof(nl_group));
27 +       if (setsockopt(fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &nl_group, sizeof(nl_group)) < 0) {
28 +               syslog(LOG_ERR, "setsockopt failed; error:%d %s", errno, strerror(errno));
29 +               close(fd);
30 +               exit(EXIT_FAILURE);
31 +       }
32         /*
33          * Register ourselves with the kernel.
34          */