Coverity reports an unchecked return value issue (CID 361266) when
calling fcntl(fd, F_SETFL, O_NONBLOCK) without checking for errors.
Fix by checking the return value and logging a warning if fcntl()
fails. The function continues to work (reading in blocking mode)
but the warning helps diagnose issues during crash backtrace handling.
Fixes: 759a29dc2d97 ("backtrace: Extend the backtrace functionality.")
Signed-off-by: Eelco Chaudron <[email protected]>
---
lib/backtrace.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/backtrace.c b/lib/backtrace.c
index 2e68bbb81..f296d216f 100644
--- a/lib/backtrace.c
+++ b/lib/backtrace.c
@@ -95,7 +95,10 @@ static bool
read_received_backtrace(int fd, void *dest, size_t len)
{
VLOG_DBG("%s fd %d", __func__, fd);
- fcntl(fd, F_SETFL, O_NONBLOCK);
+ if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) {
+ VLOG_WARN("Failed to set fd %d non-blocking: %s",
+ fd, ovs_strerror(errno));
+ }
memset(dest, 0, len);
int byte_read = read(fd, dest, len);
--
2.52.0
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev