]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: fix leak of fd on error when reading an entire file
authorJosh Durgin <josh.durgin@inktank.com>
Mon, 24 Sep 2012 22:29:13 +0000 (15:29 -0700)
committerSamuel Just <sam.just@inktank.com>
Tue, 25 Sep 2012 21:09:28 +0000 (14:09 -0700)
CID 717100: Resource leak (RESOURCE_LEAK)
At (6): Handle variable "fd" going out of scope leaks the handle.

Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
src/rbd.cc

index 5f4d85755f6de117bb1eec766533642ec4dca9bb..f4fade81cc153142e67bcc8010ed5b880a6e7a3b 100644 (file)
@@ -869,6 +869,7 @@ static int read_file(const char *filename, char *buf, size_t bufsize)
     int r = safe_read(fd, buf, bufsize);
     if (r < 0) {
       cerr << "Warning: could not read " << filename << ": " << cpp_strerror(-r) << std::endl;
+      close(fd);
       return r;
     }