From nobody Fri May 8 02:29:21 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 719D8C433F5 for ; Fri, 13 May 2022 02:21:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376526AbiEMCVq (ORCPT ); Thu, 12 May 2022 22:21:46 -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: quoted-printable 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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Release arg allocated from alloc_arg() when strdup failed in make_bprint_ar= gs(). 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/even= t-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 =3D NULL; arg->type =3D TEP_PRINT_BSTRING; arg->string.string =3D strdup(bptr); - if (!arg->string.string) + if (!arg->string.string) { + free(arg); goto out_free; + } bptr +=3D strlen(bptr) + 1; *next =3D arg; next =3D &arg->next; --=20 2.25.1 From nobody Fri May 8 02:29:21 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 476D5C433F5 for ; Fri, 13 May 2022 02:21:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376534AbiEMCVu (ORCPT ); Thu, 12 May 2022 22:21:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376515AbiEMCVl (ORCPT ); Thu, 12 May 2022 22:21:41 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BA557356D for ; Thu, 12 May 2022 19:21:40 -0700 (PDT) Received: from dggpemm500023.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KzslD33NRzGpXd; Fri, 13 May 2022 10:18:48 +0800 (CST) Received: from dggpemm500015.china.huawei.com (7.185.36.181) by dggpemm500023.china.huawei.com (7.185.36.83) 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:38 +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 2/2] libtraceevent: fix free NULL pointer in parse_arg_add() Date: Fri, 13 May 2022 10:33:08 +0800 Message-ID: <20220513023308.2400381-3-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: quoted-printable 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 To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Should not call free if parg->format is NULL. Fixes: e7a90882b05b ("tools lib traceevent: Optimize pretty_print() functio= n") 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/even= t-parse.c index 69e4d5229362..b1a07db54457 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c @@ -5461,9 +5461,11 @@ static int parse_arg_add(struct tep_print_parse **pa= rse, char *format, return 0; error: if (parg) { - free(parg->format); + if (parg->format) + free(parg->format); free(parg); } + return -1; } =20 --=20 2.25.1