Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp823406iob; Fri, 13 May 2022 13:39:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyN4BrT7bi18mDD2vre94q9O6HcFyG4FhNbvPnGveuR0it3GFt3IXRzZYEOnVzraDpGan0u X-Received: by 2002:a17:906:ce44:b0:6f4:2c9d:2d42 with SMTP id se4-20020a170906ce4400b006f42c9d2d42mr5863267ejb.503.1652474367157; Fri, 13 May 2022 13:39:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652474367; cv=none; d=google.com; s=arc-20160816; b=yQWk1nXoNPa6T4NOFQzBLP1RREBW5cWAO+MF0U+7mLlV+vBFBWglGhdyqy542Tl+Fy DlZV5X6Et2RRCe6MjYpcnF9BbR4KFsN5/I/X+/iHlkjLmZEcUrmW/rtivAbMwQoqsPXh TYLkEc5keMuyVQaYBzCb07qVtIXleR957C06joBn48Mq4XxGtH+2mKB34frGQmd2cw/Y LVPz3SSii7NbEPNmsm2YbjmoWRTWHlUTXOb+kNH23TZVrEQ+Qv6Mex/rht/aMqDZX+LU otQJnRiF01DjGtMTByLrQ3uyyzhw3/NuIaaB6GLKeMc7MPX5Hv6egbM8lELzOhQEC1ni 0g4w== 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=TMNc6vDXjuO3p98+YJoY2dvOwsqG/zG/PrJ0BnHPc2g=; b=tXEi9yKxGiHdI448SJ2iVMy028A34qs8rBl+huKtBjv4+AVWCxP7WNtkkb0v43aa90 84RT7dDjI18IKXJ1ynz85rApiwVca1Bjzlsebr/yrGSfJxNdCczb2RqJa5BK4KFs9a0H 9868M99VJFry/mQMQAHs01k/Zy9PYMZ+uZBZ7Nl/PZE//IpMFw2ETUPeKx2SgaOo4j7i n913/FxBJjIRAOzIc4dH/CpYhu3RjAiEkLOe4hL0egL4ZHqjik+umrhQTA5d2+SykIEE QGLGrMTaxEd0j4GC+NDD59X/kBef2zHCqt4VO9i/GDSSXSiiYXcn49nsUs8MnXGGcsLS jlng== 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:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k14-20020aa7c04e000000b00425dce9d98bsi2693256edo.76.2022.05.13.13.39.00; Fri, 13 May 2022 13:39:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376523AbiEMCVs (ORCPT + 99 others); Thu, 12 May 2022 22:21:48 -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: 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=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Should not call free if parg->format is NULL. Fixes: e7a90882b05b ("tools lib traceevent: Optimize pretty_print() function") 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 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 **parse, char *format, return 0; error: if (parg) { - free(parg->format); + if (parg->format) + free(parg->format); free(parg); } + return -1; } -- 2.25.1