From patchwork Tue Jul 2 10:34:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 168303 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4072641ilk; Tue, 2 Jul 2019 03:35:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFlXWinWug9/UMyCrH7Iru/58nrPHmh89fiwWufeEx0KC7TjmJm2V2lHha+pOOKJZYTUAD X-Received: by 2002:a63:4c46:: with SMTP id m6mr30878117pgl.59.1562063743326; Tue, 02 Jul 2019 03:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562063743; cv=none; d=google.com; s=arc-20160816; b=gleyg4leSV0OUZqOvOcqffrR3Wd+aR4LLIBFsIGvaVZpLqB99WGtiAwt308fiOtdwN BJwKinVvakz1Wf8Wp05wXo9in0W3LdaCdErSlWWzwfXkQj6Yj/Foxm0NSqgjUe8RUAz8 ulxdx0sxiY5GLJCsEJlUTz/u0t2xhfFwxhb+ZoE1gZ7vaOYojn7s7vS4zpfxJI98F1zj FppzkwdfYJfch4uM4x7qgXyxWeLfj7Ufq2Q0lpbSaHW67mL7gwFTAhUFgpDNbfa88NfX yxAjkuPkX/HJK2tGT66I8ifTWqKMj6fPoEaYX465jte+iHTJD6oL8aewclmlEwgyWYGG h8XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=KMNCKIxUd7C3QCEkBdcu4g6ofRmUIVRG/BHPe4FFBiI=; b=mpNyU2sKECmAwXl2DpqjGS1ootnz1YpozhZOEDZ4yyHHrIlAbA3EwDJR4nvuxzSFYG yWlx8WJ5mqHjOhI1ijP8R75DP9BeeCYuWcFc6Et9TiNXLWHrkx5RBUupFoWTPMeAd4it YZq2/8BJimdBQLmwGUaMGQV6e0eEP17jxRLRx1hbbtH327v1+bS9EkBj33VEX/I7HYaa LAmR2qqxWVLdNkv57yeFkB+TM+DJUBG0MbqV8fk6BOakeLTEqN+RTU0bgsDvq3wUISlr SvMe3OBy7zW5biIKs2DIwBKvWqZmuGDTKLjSw4i1YQ3mFdGQkWOEIxkaKsRfR1yjUvZ5 qR2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b3Ynb3mm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j23si12421035pll.214.2019.07.02.03.35.43; Tue, 02 Jul 2019 03:35:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b3Ynb3mm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727069AbfGBKfD (ORCPT + 30 others); Tue, 2 Jul 2019 06:35:03 -0400 Received: from mail-ot1-f67.google.com ([209.85.210.67]:46048 "EHLO mail-ot1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725801AbfGBKfC (ORCPT ); Tue, 2 Jul 2019 06:35:02 -0400 Received: by mail-ot1-f67.google.com with SMTP id x21so16635304otq.12 for ; Tue, 02 Jul 2019 03:35:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KMNCKIxUd7C3QCEkBdcu4g6ofRmUIVRG/BHPe4FFBiI=; b=b3Ynb3mmyQPqXrGhUFTeBcfcKHtyocPl8Z41p2F8I32GBNu0jF2BwO2+v3JgI33/vX jdTP5yPdtLr0AmtRijQulnFrapU3F7Wo1t9ouWCA8DB3JJmF+5U2+qFa/t67GXudzCMz ly/Us9RlBLH/YWRpgziYH+onbCeHqjhF+Jsx8f+BdbQnJpk0sZsc1lMdFG2vqOxBUmi3 zREazE8Zg6hRzYOeK/wcN6BSghqPHghcuZXM/aLU82P664LzADeiNUaoRo96TUXapNFl VMQxHdl/BOL+DLppX1ABrQiPd4KpJ6Qar4Ka5KVHxxtBxrd0PruJ1D9m2pAFFESgzNds V19Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KMNCKIxUd7C3QCEkBdcu4g6ofRmUIVRG/BHPe4FFBiI=; b=T3LRONcddq5FYPLtvwQLApURaiguPuBowGSFl2dgVmnxcCwvT44VxM+oHZb9pUYVKt wd+mvxW8A9e91ecPpFyBygXZxbVx8w9dfTAmGknctLxsQ9H5wT8yJNEyzZiZvSUJmJz4 prTFlOl/kSNFGczsEsNWgVfv9z2n/91It1OJrWVLmfIuvNH36gF78/wB5012sgAHdqOa MyD6S/84q9kb4dkM7lv2TSNWqAbYEnCSZt2/h1pot1Ur6rwSCUqlZB2xIt/FNhToVAv/ TZNikutlWu/sNAnLYpMxOrUGZ0JXmm/4Rt3qj8vsV153WyeRBIQS8l1Iql2GYE8EDTGt xElA== X-Gm-Message-State: APjAAAVBzDy6XLDPKFEU5Q544cFy2KKhu6n/J/tRzHwVV0Q++MzSEt6A LbH18aI/VtH0AFrYgUzZbM+aUA== X-Received: by 2002:a9d:6ac9:: with SMTP id m9mr19994522otq.242.1562063701875; Tue, 02 Jul 2019 03:35:01 -0700 (PDT) Received: from localhost.localdomain (li964-79.members.linode.com. [45.33.10.79]) by smtp.gmail.com with ESMTPSA id 61sm5139805otx.8.2019.07.02.03.34.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jul 2019 03:35:01 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Mathieu Poirier , Suzuki K Poulose , Andi Kleen , "David S. Miller" , Davidlohr Bueso , Rasmus Villemoes , Jin Yao , Song Liu , Adrian Hunter , Alexios Zavras , Thomas Gleixner , Changbin Du , Eric Saint-Etienne , Konstantin Khlebnikov , Thomas Richter , Alexey Budankov , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Leo Yan Subject: [PATCH v1 02/11] perf stat: Smatch: Fix use-after-freed pointer Date: Tue, 2 Jul 2019 18:34:11 +0800 Message-Id: <20190702103420.27540-3-leo.yan@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190702103420.27540-1-leo.yan@linaro.org> References: <20190702103420.27540-1-leo.yan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Based on the following report from Smatch, fix the use-after-freed pointer. tools/perf/builtin-stat.c:1353 add_default_attributes() warn: passing freed memory 'str'. The pointer 'str' has been freed but later it is still passed into the function parse_events_print_error(). This patch fixes this use-after-freed issue. Signed-off-by: Leo Yan --- tools/perf/builtin-stat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 8a35fc5a7281..de0f6d0e96a2 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -1349,8 +1349,8 @@ static int add_default_attributes(void) fprintf(stderr, "Cannot set up top down events %s: %d\n", str, err); - free(str); parse_events_print_error(&errinfo, str); + free(str); return -1; } } else {