[dm-devel] [PATCH 12/39] libmultipath/uevent.c: handle errors from setsockopt()
Hannes Reinecke
hare at suse.de
Thu Jun 16 09:47:18 UTC 2016
Found by coverity.
Signed-off-by: Hannes Reinecke <hare at suse.com>
---
libmultipath/uevent.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
index fb8b4a7..ff4bc86 100644
--- a/libmultipath/uevent.c
+++ b/libmultipath/uevent.c
@@ -291,8 +291,12 @@ int failback_listen(void)
}
/* enable receiving of the sender credentials */
- setsockopt(sock, SOL_SOCKET, SO_PASSCRED,
- &feature_on, sizeof(feature_on));
+ retval = setsockopt(sock, SOL_SOCKET, SO_PASSCRED,
+ &feature_on, sizeof(feature_on));
+ if (retval < 0) {
+ condlog(0, "failed to enable credential passing, exit");
+ goto exit;
+ }
} else {
/* Fallback to read kernel netlink events */
@@ -330,8 +334,11 @@ int failback_listen(void)
condlog(3, "receive buffer size for socket is %u.", rcvsz);
/* enable receiving of the sender credentials */
- setsockopt(sock, SOL_SOCKET, SO_PASSCRED,
- &feature_on, sizeof(feature_on));
+ if (setsockopt(sock, SOL_SOCKET, SO_PASSCRED,
+ &feature_on, sizeof(feature_on)) < 0) {
+ condlog(0, "error on enabling credential passing for socket");
+ exit(1);
+ }
retval = bind(sock, (struct sockaddr *) &snl,
sizeof(struct sockaddr_nl));
--
2.6.6
More information about the dm-devel
mailing list