Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp179336imd; Wed, 31 Oct 2018 16:55:32 -0700 (PDT) X-Google-Smtp-Source: AJdET5e/+7gGm7ZB2HmPs34f1kNc/53BVZISd0UTv4Aqkbf85liwx//2xLAiWuYzcQqInq95OXoi X-Received: by 2002:a63:5c61:: with SMTP id n33-v6mr4845292pgm.1.1541030132183; Wed, 31 Oct 2018 16:55:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541030132; cv=none; d=google.com; s=arc-20160816; b=MiufrFKMObqvSq6XH2RyZrO6UcOa9mip9I0TlonSqgQxszpotCZ2FecvDAODPQju9q uoG1xkq1RbJInr38TjY85AdO5S1t48f3YDeDLqyGYbvyMsbGNUQziUGOt/KT5Yp367vU 1ijhLyRp6TZLe4THo4mTsDXcxm3fh7W11nz8bH79FnGjC/3ZH/cKV06Wa4d4s3p6fJn2 +dru7/EcIe7c7mYYoSsVb0FkUEt04WqhpOQcNuwqUDM08T/Gm/ZU9QDAq7+jNW/dLg9g GvkxJ0u0uc2ClZlD9TDlI/39YCecToebvrv98fUdvSe5pOQtpBZa17BIfLe+c5/gkaLv LdvQ== 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=RNMW4PFYLhLCjJaWslnNK2FYBTePfY0QAy2DmwvBcIw=; b=0cRC1aw9KRqWklEfv5fECmyQhmSGxGQCsHHqEgP6LfsMqhWWOVC6a7gNJRxKQ3x1VE JU0sNrzPDIv5iaZ1IT7/eV+f5xTRL+HJPvgNkPet+pY6dzr1DId+klZq8QI+RKLR1DJX QABqMVfb61pgpM4TbmQc2NReuUgXUa4wISNDSSkEhm05UaGNS04NDVHkx1y0vNErf1xO jkszEcfD4BFfTTGpIFd1GBBsAVeTpLa1qgREIH3+nXY8XmBNCEW4sc89r/xwvcaX7H4R 5Yxi6ePH28sXA+qFjCjfoZQxfie4qVNNKQG0snT5eEC6N3ecAj0ORH7OIR7jtZxScbDU 14CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qnMWHs01; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c1-v6si4195786pld.11.2018.10.31.16.55.17; Wed, 31 Oct 2018 16:55:32 -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=@kernel.org header.s=default header.b=qnMWHs01; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727972AbeKAIyB (ORCPT + 99 others); Thu, 1 Nov 2018 04:54:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:52956 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727552AbeKAIGL (ORCPT ); Thu, 1 Nov 2018 04:06:11 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8D1E72082E; Wed, 31 Oct 2018 23:06:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027161; bh=gyYrjgLiCJXkKVjzf2Xc6952N5UhCjlaU81NE6QViJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qnMWHs0149XaQID+j+JWZpjqWYyY+JJohOfru9v4gGOrEc08OgOLAjRoc5MuEzAuZ DoLvMPK23A6UhXBx7ZIO2k5vhI4/N+jXLr3+zJR4HY+1ECyRbaWl6UDepaXM5pjiNb UoID4BpDPbT0d6W5BvVPpNKLTsxVNI9uUg1Nw/cg= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sanskriti Sharma , Joe Lawrence , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH AUTOSEL 4.19 020/146] perf tools: Free 'printk' string in parse_ftrace_printk() Date: Wed, 31 Oct 2018 19:03:35 -0400 Message-Id: <20181031230541.28822-20-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sanskriti Sharma [ Upstream commit 9c8a182e5a73e01afd11742a2ab887bf338fdafd ] parse_ftrace_printk() tokenizes and parses a line, calling strdup() each iteration. Add code to free this temporary format string duplicate. Fixes the following coverity complaints: Error: RESOURCE_LEAK (CWE-772): tools/perf/util/trace-event-parse.c:158: overwrite_var: Overwriting "printk" in "printk = strdup(fmt + 1)" leaks the storage that "printk" points to. tools/perf/util/trace-event-parse.c:162: leaked_storage: Variable "printk" going out of scope leaks the storage it points to. Signed-off-by: Sanskriti Sharma Reviewed-by: Jiri Olsa Cc: Joe Lawrence Link: http://lkml.kernel.org/r/1538490554-8161-4-git-send-email-sansharm@redhat.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/util/trace-event-parse.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c index e76214f8d596..b15a9bf1837b 100644 --- a/tools/perf/util/trace-event-parse.c +++ b/tools/perf/util/trace-event-parse.c @@ -158,6 +158,7 @@ void parse_ftrace_printk(struct tep_handle *pevent, printk = strdup(fmt+1); line = strtok_r(NULL, "\n", &next); tep_register_print_string(pevent, printk, addr); + free(printk); } } -- 2.17.1