Skip to content

Commit

Permalink
rbd: Release resource before return
Browse files Browse the repository at this point in the history
Close file before return.
Fix coverity issue: CID 1019579

Signed-off-by: Li Wang <[email protected]>
Reported-by: Xianxia Xiao <[email protected]>
Reviewed-by: Josh Durgin <[email protected]>
  • Loading branch information
dragonylffly authored and jdurgin committed Nov 25, 2013
1 parent d6c8830 commit 524f666
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/rbd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1125,8 +1125,10 @@ static int do_export_diff(librbd::Image& image, const char *fromsnapname,
::encode(endsize, bl);

r = bl.write_fd(fd);
if (r < 0)
if (r < 0) {
close(fd);
return r;
}
}

ExportContext ec(&image, fd, info.size);
Expand All @@ -1139,8 +1141,6 @@ static int do_export_diff(librbd::Image& image, const char *fromsnapname,
bufferlist bl;
::encode(tag, bl);
r = bl.write_fd(fd);
if (r < 0)
return r;
}

out:
Expand Down

0 comments on commit 524f666

Please sign in to comment.