Fix runas: don't attempt close negative fd
[lttng-tools.git] / src / common / runas.c
index debc95926e7d04fa7989ca8f62bc2b85e0e8aaf6..0a588482644f5138b138edfc39ab3002ebb48aeb 100644 (file)
@@ -402,11 +402,14 @@ int send_fd_to_master(struct run_as_worker *worker, enum run_as_cmd cmd, int fd)
                ret = -1;
        }
 
+       if (fd < 0) {
+               goto end;
+       }
        ret_close = close(fd);
        if (ret_close < 0) {
                PERROR("close");
        }
-
+end:
        return ret;
 }
 
@@ -466,6 +469,9 @@ int cleanup_received_fd(enum run_as_cmd cmd, int fd)
                return 0;
        }
 
+       if (fd < 0) {
+               return 0;
+       }
        ret = close(fd);
        if (ret < 0) {
                PERROR("close error");
This page took 0.024403 seconds and 5 git commands to generate.