From patchwork Mon Feb 27 12:20:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9593057 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1434F601D7 for ; Mon, 27 Feb 2017 12:23:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 077D1282ED for ; Mon, 27 Feb 2017 12:23:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EF2CA283E9; Mon, 27 Feb 2017 12:23:43 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A5621282ED for ; Mon, 27 Feb 2017 12:23:43 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ciKIe-0006nt-3R; Mon, 27 Feb 2017 12:21:08 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ciKIc-0006nn-DQ for xen-devel@lists.xenproject.org; Mon, 27 Feb 2017 12:21:06 +0000 Received: from [85.158.139.211] by server-12.bemta-5.messagelabs.com id 01/C7-13179-1B914B85; Mon, 27 Feb 2017 12:21:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOLMWRWlGSWpSXmKPExsXitHRDpO5GyS0 RBodPClt83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBnTtuxjLzjDXtH5/CR7A+N0ti5GTg4JAX+J C/PvMoLYbALKEj87e8HiIgJ6Ek0HnoPFmQWKJR5s3MDSxcjBIQxU//pSBEiYRUBVYsPmecwgN q+AhUTf+rlQI+UldrVdZAWxhQQUJDqmH2OCqBGUODnzCQvESAmJgy9eME9g5J6FJDULSWoBI9 MqRvXi1KKy1CJdc72kosz0jJLcxMwcXUMDU73c1OLixPTUnMSkYr3k/NxNjMBAYACCHYzHJjs fYpTkYFIS5XX7vDlCiC8pP6UyI7E4I76oNCe1+BCjDAeHkgTvAoktEUKCRanpqRVpmTnAkIRJ S3DwKInw2oCkeYsLEnOLM9MhUqcYdTluHD/whkmIJS8/L1VKnDcPpEgApCijNA9uBCw+LjHKS gnzMgIdJcRTkFqUm1mCKv+KUZyDUUmYdx/IFJ7MvBK4Ta+AjmACOmK28UaQI0oSEVJSDYxLnd 64neP6aWR3YH/Q9rTohMiXT/kOTbosuv2jb9N786hrnNN//zqwq/O0Jduvsty8WbyfXSLDosU Cm7c+UNCWlZsxt0thdoUzY9PNQ/9ZN3Nul4m4m7ty1apWuYmt/38/fPfuaqamYYTx5OUd7zo0 1s5WfJ7t8ps/02yZkr/QCr/T93k1VjIosRRnJBpqMRcVJwIAockGpooCAAA= X-Env-Sender: prvs=2241cd559=wei.liu2@citrix.com X-Msg-Ref: server-11.tower-206.messagelabs.com!1488198063!69106837!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 47752 invoked from network); 27 Feb 2017 12:21:04 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-11.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 27 Feb 2017 12:21:04 -0000 X-IronPort-AV: E=Sophos;i="5.35,214,1484006400"; d="scan'208";a="409963812" From: Wei Liu To: Xen-devel Date: Mon, 27 Feb 2017 12:20:26 +0000 Message-ID: <20170227122026.12740-1-wei.liu2@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Cc: Wei Liu , Paul Durrant , Ian Jackson Subject: [Xen-devel] [PATCH] libs/devicemodel: free xencall handle in error path in _open() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Change the allocation to use calloc to get zeroed structure. Free xencall handler in error path. Spotted by Coverity. Signed-off-by: Wei Liu Reviewed-by: Paul Durrant Acked-by: Ian Jackson --- tools/libs/devicemodel/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c index 19ebef63b3..a85cb49c22 100644 --- a/tools/libs/devicemodel/core.c +++ b/tools/libs/devicemodel/core.c @@ -24,7 +24,7 @@ xendevicemodel_handle *xendevicemodel_open(xentoollog_logger *logger, unsigned open_flags) { - xendevicemodel_handle *dmod = malloc(sizeof(*dmod)); + xendevicemodel_handle *dmod = calloc(1, sizeof(*dmod)); int rc; if (!dmod) @@ -54,6 +54,7 @@ xendevicemodel_handle *xendevicemodel_open(xentoollog_logger *logger, err: xtl_logger_destroy(dmod->logger_tofree); + xencall_close(dmod->xcall); free(dmod); return NULL; }