From patchwork Mon Nov 18 07:40:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Wang X-Patchwork-Id: 3195521 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 791C69F345 for ; Mon, 18 Nov 2013 07:40:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 93643206D6 for ; Mon, 18 Nov 2013 07:40:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E4470206D0 for ; Mon, 18 Nov 2013 07:40:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751203Ab3KRHko (ORCPT ); Mon, 18 Nov 2013 02:40:44 -0500 Received: from m53-178.qiye.163.com ([123.58.178.53]:40037 "EHLO m53-178.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751079Ab3KRHkm (ORCPT ); Mon, 18 Nov 2013 02:40:42 -0500 Received: from localhost.localdomain (unknown [222.240.177.34]) by m53-178.qiye.163.com (HMail) with ESMTPA id 15C2D1BF007C; Mon, 18 Nov 2013 15:40:38 +0800 (CST) From: Li Wang To: Cc: Sage Weil , Li Wang Subject: [PATCH 1/2] rbd: Release resource before return Date: Mon, 18 Nov 2013 15:40:18 +0800 Message-Id: <144b72fe66a7e9b851c551fd929648d470674a46.1384760071.git.liwang@ubuntukylin.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: In-Reply-To: References: X-HM-Spam-Status: e1koWUFPN1dZCBgUCR5ZQUpMVUNJQkJCQkJJSExLTUtOTldZCQ4XHghZQV koKz0kKzooKCQyNSQzPjo*PilBS1VLQDYjJCI#KCQyNSQzPjo*PilBS1VLQCsvKSQ1NCQyNSQzPj o*PilBSVVLQDg0LjUvKSIkODVBS1VLQCk#PDI0NSQ6KDI6QUtVS0ArKTQtMjU4PiQzLjU6NUFLVU tAPyI1OjYyOCQyKyQ1NCQyNSQzPjo*PilBS1VLQCk#OjckMiskMjUkKTk3JDI1JDM#Oj8#KUFKSV VLQDYuNy8yJCk4Ky8kPzI9PT4pPjUvJDI1JDM#Oj8#KUFJVUtAMiskLzQ*OiIkODUvJEskSktLQU tVS0AyKyROJDYyNS4vPiQ4NS8kSyRKS0FLVUtAMiskSEskNjI1Li8#JDg1LyRLJE5LQUtVS0AyKy RKJDM0LikkODUvJEskSktLQUtVS0AyKyRKJDYyNS4vPiQ4NS8kSyRKS0FLVUtAKC45JD5BSlVOTk A9NSQoLjkkPjUsNCk*KCQzNzEkSktLSUtKQUtVSUNZBg++ X-HM-Sender-Digest: e1kSHx4VD1lBWUc6MQg6Cjo4LDo4EDorKjhIOj4qOkMwCjFVSlVKSENP TE1LT0hDTExOVTMWGhIXVRcSDBoVHDsOGQ4VDw4QAhcSFVUYFBZFWVdZDB4ZWUEdGhcIHldZCAFZ QUpCTEM3V1kSC1lBWUlJSVVJT0tVSkxMVUhPWQY+ Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Close file before return. Fix coverity issue: CID 1019579 Signed-off-by: Li Wang Reported-by: Xianxia Xiao --- src/rbd.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rbd.cc b/src/rbd.cc index 41cd243..9556fb8 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -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: