From 55f72301baf5fe7d116974d3d2f46950a147c7cf Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Mon, 24 Sep 2012 15:29:13 -0700 Subject: [PATCH] rbd: fix leak of fd on error when reading an entire file CID 717100: Resource leak (RESOURCE_LEAK) At (6): Handle variable "fd" going out of scope leaks the handle. Signed-off-by: Josh Durgin --- src/rbd.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rbd.cc b/src/rbd.cc index 5f4d85755f6..f4fade81cc1 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -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; }