From bc90fe4c715dfbb6637e2aa6727662dd5d30bb4f Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Thu, 24 Mar 2022 12:02:06 +0100 Subject: [PATCH] virtio-devices: vhost-user: fs: Don't close file descriptor The file descriptor provided to fs_slave_map() and fs_slave_io() is passed as a AsRawFd trait, meaning the caller owns it. For that reason, there's no need for these functions to close the file descriptor as it will be closed later on anyway. Signed-off-by: Sebastien Boeuf --- virtio-devices/src/vhost_user/fs.rs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/virtio-devices/src/vhost_user/fs.rs b/virtio-devices/src/vhost_user/fs.rs index 1cb9517c5..0b24fc55a 100644 --- a/virtio-devices/src/vhost_user/fs.rs +++ b/virtio-devices/src/vhost_user/fs.rs @@ -108,11 +108,6 @@ impl VhostUserMasterReqHandler for SlaveReqHandler { if ret == libc::MAP_FAILED { return Err(io::Error::last_os_error()); } - - let ret = unsafe { libc::close(fd.as_raw_fd()) }; - if ret == -1 { - return Err(io::Error::last_os_error()); - } } Ok(0) @@ -271,11 +266,6 @@ impl VhostUserMasterReqHandler for SlaveReqHandler { } } - let ret = unsafe { libc::close(fd.as_raw_fd()) }; - if ret == -1 { - return Err(io::Error::last_os_error()); - } - Ok(done) } }