mirror of
https://github.com/ceph/ceph
synced 2024-12-18 09:25:49 +00:00
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 <josh.durgin@inktank.com>
This commit is contained in:
parent
5b22c1d68d
commit
55f72301ba
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user