Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp963217iob; Fri, 13 May 2022 17:53:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJye6cMcEQH4v3F11phVHE1onesnPskK9k29PG3NPQ/J8U/rUO8eU6h1UHKThop3pjDauySN X-Received: by 2002:a5d:6483:0:b0:20c:5c21:5c8c with SMTP id o3-20020a5d6483000000b0020c5c215c8cmr5856186wri.86.1652489604559; Fri, 13 May 2022 17:53:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652489604; cv=none; d=google.com; s=arc-20160816; b=wQAaHPvoT/4g56204d+jCNq37HJGcqz7E/qJA6wPdpDT4dftR2VQ2xR7I3DEBT65OK /l1C9lqF7913GjWmVyczoTD1rsj9BlC28wqMEVvK/GoVmKvhRbtsSqMCjIw0sX7QcAlK emB9TmTUPKgWmBl9CzMC7sGY8OlblDuZZ95JSzTTf88taxBOM55mFvglHDj76x/MURQy 6hTexH8QOVuJO0jfeypZvwNwRwsHCDgTzIcYacYO3aFURoyvJuq1Hkgbr14om3E1pO/X z6gbb01Rq0vZp0vSZ5ixe/y9n7euDapa5sTxpoCifOqs7KJUcSTcTD7mak34ObDzsaAO faQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from; bh=niWWJAcuxG2dV/c8+4Nh3Cf9fqhK6WLyJ9Wl5FH0GVA=; b=USjIBCwCNgyTU0wPvlFo16iQDBEzYsxokD9diPQ7r95B630GMeiLVQxHy/WfDlqsOb 2wqZ6xN0aybbshpu+jjXn1WOzSgG3/gXe4KApSXiCp+PM9a+bP9YMoiWIkH5ed8hbJ86 wSWD/+quLmAw3CofwEkPZVw1jEmx6XXxeA6BueDT7YMUcEzp/eIDTkbQO0+e4V+WQW1G KDn9U1WQwiAzyOT1c8+Ak3eRnEdWhvCBiVk8rouFaPxhFFWsQ2f0hGb69jQOs9ae8bE5 /fpYKobvZXJfm8Po23AFMZD1kknd99UWNIUpuyfET3zIc+5uAGuaOYqElVyWxUs6FkYu bGGQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s13-20020a5d4ecd000000b0020918369598si3047868wrv.1029.2022.05.13.17.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 17:53:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3F9ED346657; Fri, 13 May 2022 16:29:11 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376520AbiEMCVp (ORCPT + 99 others); Thu, 12 May 2022 22:21:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376514AbiEMCVl (ORCPT ); Thu, 12 May 2022 22:21:41 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A84E578FF0 for ; Thu, 12 May 2022 19:21:39 -0700 (PDT) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Kzsn31tr4zfZs9; Fri, 13 May 2022 10:20:23 +0800 (CST) Received: from dggpemm500015.china.huawei.com (7.185.36.181) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 13 May 2022 10:21:37 +0800 Received: from huawei.com (10.175.103.91) by dggpemm500015.china.huawei.com (7.185.36.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 13 May 2022 10:21:37 +0800 From: Wang ShaoBo CC: , , , , , , , Subject: [PATCH 1/2] libtraceevent: fix memleak in make_bprint_args() Date: Fri, 13 May 2022 10:33:07 +0800 Message-ID: <20220513023308.2400381-2-bobo.shaobowang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220513023308.2400381-1-bobo.shaobowang@huawei.com> References: <20220513023308.2400381-1-bobo.shaobowang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500015.china.huawei.com (7.185.36.181) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Release arg allocated from alloc_arg() when strdup failed in make_bprint_args(). Fixes: a6d2a61ac653 ("tools lib traceevent: Remove some die() calls") Signed-off-by: Wang ShaoBo --- tools/lib/traceevent/event-parse.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 8e24c4c78c7f..69e4d5229362 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -4507,8 +4507,10 @@ static struct tep_print_arg *make_bprint_args(char *fmt, void *data, int size, s arg->next = NULL; arg->type = TEP_PRINT_BSTRING; arg->string.string = strdup(bptr); - if (!arg->string.string) + if (!arg->string.string) { + free(arg); goto out_free; + } bptr += strlen(bptr) + 1; *next = arg; next = &arg->next; -- 2.25.1