]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: Release resource before return
authorLi Wang <liwang@ubuntukylin.com>
Mon, 18 Nov 2013 07:40:18 +0000 (15:40 +0800)
committerJosh Durgin <josh.durgin@inktank.com>
Mon, 25 Nov 2013 21:57:40 +0000 (13:57 -0800)
Close file before return.
Fix coverity issue: CID 1019579

Signed-off-by: Li Wang <liwang@ubuntukylin.com>
Reported-by: Xianxia Xiao <xianxiaxiao@ubuntukylin.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
src/rbd.cc

index 41cd243735520fddbc2f54c23b280f7362b827d5..9556fb842eae877ce328258a25df9b12fabd9484 100644 (file)
@@ -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);
@@ -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: