From patchwork Mon Mar 4 22:39:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Sandeen X-Patchwork-Id: 2214671 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id A8682DF5B1 for ; Mon, 4 Mar 2013 21:40:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932616Ab3CDVke (ORCPT ); Mon, 4 Mar 2013 16:40:34 -0500 Received: from nat-pool-rdu.redhat.com ([66.187.233.202]:59164 "EHLO bp-05.lab.msp.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932484Ab3CDVkb (ORCPT ); Mon, 4 Mar 2013 16:40:31 -0500 Received: by bp-05.lab.msp.redhat.com (Postfix, from userid 0) id B2BFD1E09C3; Mon, 4 Mar 2013 16:40:07 -0600 (CST) From: Eric Sandeen To: linux-btrfs@vger.kernel.org Cc: Eric Sandeen Subject: [PATCH 02/14] btrfs-progs: close fd on do_convert error returns Date: Mon, 4 Mar 2013 16:39:52 -0600 Message-Id: <1362436804-16766-3-git-send-email-sandeen@redhat.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1362436804-16766-1-git-send-email-sandeen@redhat.com> References: <1362436804-16766-1-git-send-email-sandeen@redhat.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org stops an fd leak that Coverity found. Signed-off-by: Eric Sandeen --- convert.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/convert.c b/convert.c index 2b3f42f..4a75895 100644 --- a/convert.c +++ b/convert.c @@ -2277,7 +2277,8 @@ err: int do_convert(const char *devname, int datacsum, int packing, int noxattr) { - int i, fd, ret; + int i, ret; + int fd = -1; u32 blocksize; u64 blocks[7]; u64 total_bytes; @@ -2407,6 +2408,8 @@ int do_convert(const char *devname, int datacsum, int packing, int noxattr) printf("conversion complete.\n"); return 0; fail: + if (fd != -1) + close(fd); fprintf(stderr, "conversion aborted.\n"); return -1; }