From patchwork Tue Aug 28 09:57:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 10578131 X-Patchwork-Delegate: hal@mellanox.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2AE6E14E1 for ; Tue, 28 Aug 2018 09:57:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19B1A28F47 for ; Tue, 28 Aug 2018 09:57:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E3602901F; Tue, 28 Aug 2018 09:57:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B53D928F47 for ; Tue, 28 Aug 2018 09:57:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727271AbeH1Nsd (ORCPT ); Tue, 28 Aug 2018 09:48:33 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:52404 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727094AbeH1Nsc (ORCPT ); Tue, 28 Aug 2018 09:48:32 -0400 Received: by mail-wm0-f65.google.com with SMTP id y139-v6so1248625wmc.2 for ; Tue, 28 Aug 2018 02:57:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dev-mellanox-co-il.20150623.gappssmtp.com; s=20150623; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=+SHY95EjDmWrr2lsw+QbYE4/sUSxnSVyCEP+2MKhEr8=; b=TbXaibByAbpxuQeUbG8ttJQp0AEc5Zx0Vgn0lKfe7BKic9fFyuJ7i1jCIEn1huh0sM n8cMRk8bZRAt1XeYespItg/ZZAeMN1zCy6sxcofDXF/4pjyNOWNXMQ/HlTP0920dDQ04 ZdyrUD2zaBm3STeCo1kpo3qRxp/uYrQhO/4Q8eipCyOCricAguibeApWtm2FlwiLuqfh a/8TUK10hs89P4UwL3ArxsiZDKGvBYf4cxjO9ZeqPhKh3v1hxWeg10fRtuCVJEILWDls 4UG+tkCmocTdlAXgAt0ooFKIEB321++N0ziT0j0SZRba1ZgouOiuygRdW7tmhkJBVOns zOfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=+SHY95EjDmWrr2lsw+QbYE4/sUSxnSVyCEP+2MKhEr8=; b=GIXy0tW6P6YSLuRXAJAeQDTKuaMofu8TV/5x68L+uVJv90siVz4ajmXkaZ7f9v5Q26 v5nOw/niqDOea19Q7v3oQxNoflxbKdyHFWtP/XM5hZu29Xfze78fgnnaZ60tTaGPgrSa a9pGBs2VPU/uSiw5nJCBxX8Bxf3Nuz8bWgKxVK+JTKh1VsjMTlx/jnvu2pI1ioAKFU02 iveLgsR0sdIBJ4Ilm4OcHx4b8XYL6/SM5PWaJj4krIlemB0ragLzEHu+vmEs4/1Txn8F VYogpu6tO0ub+aGOsGsN7FyTgFyDPRO8pN6M70fRz1pNyBDLCOOE5z3p/zhGguOHQLST DP0w== X-Gm-Message-State: APzg51Cbx33Xh1ZaydC3t/Sjt9NVuyL/zR+leDxezp1pkZuKeIORykYJ g9R9epji6SEdCuyqhoQb9ndZYlNLp8A= X-Google-Smtp-Source: ANB0Vdb3E+iWyFOc5jEs4VOS63eqd30ne9/aIyDOriiTF20m9Mq3QAr601fzpRxr55/8Y6hjOleBrg== X-Received: by 2002:a1c:ac07:: with SMTP id v7-v6mr810948wme.110.1535450259066; Tue, 28 Aug 2018 02:57:39 -0700 (PDT) Received: from [192.168.1.183] (c-73-142-227-196.hsd1.ma.comcast.net. [73.142.227.196]) by smtp.googlemail.com with ESMTPSA id 1-v6sm1546332wmf.47.2018.08.28.02.57.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Aug 2018 02:57:38 -0700 (PDT) To: Honggang LI Cc: "linux-rdma@vger.kernel.org" From: Hal Rosenstock Subject: [PATCH opensm] osmtest/osmtest.c: Close file before exit function osmtest_create_inventory_file Message-ID: <3221fd97-731a-6e40-a9c1-f58d97c48b5b@dev.mellanox.co.il> Date: Tue, 28 Aug 2018 05:57:39 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Language: en-US Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If for some reason we get an error when trying to write the inventory file, we first need to close the file and then exit the function. Signed-off-by: Dan Ben Yosef Signed-off-by: Alex Netes Acked-by: Honggang Li --- osmtest/osmtest.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/osmtest/osmtest.c b/osmtest/osmtest.c index c8c8e71..79e8af8 100644 --- a/osmtest/osmtest.c +++ b/osmtest/osmtest.c @@ -2545,22 +2545,24 @@ osmtest_create_inventory_file(IN osmtest_t * const p_osmt) /* HACK: the order is important: nodes ports paths */ status = osmtest_write_all_node_recs(p_osmt, fh); if (status != IB_SUCCESS) - goto Exit; + goto CloseFile; status = osmtest_write_all_port_recs(p_osmt, fh); if (status != IB_SUCCESS) - goto Exit; + goto CloseFile; if (!p_osmt->opt.ignore_path_records) { status = osmtest_write_all_path_recs(p_osmt, fh); if (status != IB_SUCCESS) - goto Exit; + goto CloseFile; } status = osmtest_write_all_link_recs(p_osmt, fh); if (status != IB_SUCCESS) - goto Exit; + goto CloseFile; + +CloseFile: fclose(fh); Exit: