From patchwork Wed Feb 17 14:04:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 8339281 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7370BC0554 for ; Wed, 17 Feb 2016 14:06:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9E8692034A for ; Wed, 17 Feb 2016 14:06:53 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CF842201F4 for ; Wed, 17 Feb 2016 14:06:51 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aW2iY-0002Wd-BL; Wed, 17 Feb 2016 14:04:34 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aW2iV-0002VX-QM for xen-devel@lists.xen.org; Wed, 17 Feb 2016 14:04:31 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id C0/8F-29293-FED74C65; Wed, 17 Feb 2016 14:04:31 +0000 X-Env-Sender: prvs=848fde4e6=Ian.Campbell@citrix.com X-Msg-Ref: server-4.tower-206.messagelabs.com!1455717867!23060080!2 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31019 invoked from network); 17 Feb 2016 14:04:29 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-4.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 17 Feb 2016 14:04:29 -0000 X-IronPort-AV: E=Sophos;i="5.22,460,1449532800"; d="scan'208";a="338850817" From: Ian Campbell To: , , Date: Wed, 17 Feb 2016 14:04:14 +0000 Message-ID: <1455717855-2344-2-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1455717855-2344-1-git-send-email-ian.campbell@citrix.com> References: <1455717855-2344-1-git-send-email-ian.campbell@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Ian Campbell Subject: [Xen-devel] [PATCH 2/3] xl: use xrealloc in domain create X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable 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 Using bare realloc risks leaking the old pointer if the realloc fails. Since xrealloc exits on such failures, drop the error handling. Noticed while fixing, but not related to, CID 1055898. Signed-off-by: Ian Campbell Acked-by: Ian Jackson --- tools/libxl/xl_cmdimpl.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index e819ee6..7ba40c0 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -2799,12 +2799,8 @@ static uint32_t create_domain(struct domain_create *dom_info) return ERROR_FAIL; } /* allocate space for the extra config plus two EOLs plus \0 */ - config_data = realloc(config_data, config_len + config_data = xrealloc(config_data, config_len + strlen(extra_config) + 2 + 1); - if (!config_data) { - fprintf(stderr, "Failed to realloc config_data\n"); - return ERROR_FAIL; - } config_len += sprintf(config_data + config_len, "\n%s\n", extra_config); }