Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3487064imu; Sun, 11 Nov 2018 16:12:17 -0800 (PST) X-Google-Smtp-Source: AJdET5f5788CaJ8sWuuTPqsGwJFjhtmG+KXlGyji3ie9lyt2g0HYDvlOym0bg1ht0tTFzjyjjMQj X-Received: by 2002:a17:902:7402:: with SMTP id g2mr2303937pll.198.1541981537676; Sun, 11 Nov 2018 16:12:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981537; cv=none; d=google.com; s=arc-20160816; b=gI6w8EAk+ie/Ghtq2Xg291RbFH7i8BUCMz2xrA32GOoXtQq/wqbZWglK5kACrcRonp mZnKX878NM0MHZ1ifBptiB5mhjPpad3yOMZPSuXT1EtP0KyPz+4YfqaC9xGQjNnOZbuf P5NPTh4+yAYS2GYeAsbZfW8RqvmZpbDs8X2TXpojfBuHTy914VyL3szJThuJJqbMbRES bGHA+PdClwc+CYuALYdyhI4eDAbQ5+SX9aoDkcYx23bMIdRBmkFd6Axf7CVjzxsU1/mY +4ntw7UuhmE8tF8ieb7yaaLLu6V94CItSbwDgbuULVY6R7xfIEpQxjwzOBLhUPDzTT2l CWVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6SIMGx1CDdB24m0BUHp6xkH85rmEAsezXIMOGymVNTE=; b=ySxeM0JtueXfCuSbltIEpJ0MjCfZcU5XAoUXAUwGHMsOXaZG53a+mKBxJRr7JAFzxB 50uj+aAOEq9F+d9LqNiyuSlS0Kq0pCQb23cmpHIsEQYDeFstX+5wzD7Q9Cy56wy7t4R6 ckHgB4PiW+ptzIe9J/GgfNb9QgVtjTzm0tYwXPLHaFLbPQkKrON48kJGSYXKiyGkqi11 tYW8iQUBmx75Qv03LcrpeGENFeLN4pMX4xbc354ZleOvmwGtXRgqHmDtwVixyGGsxcc+ CwNGuJhBTEUFp7PeZKVWAFps6wtan8/GJg6hshjR3YNf3bGAs/lmQ4x5fPT0XZvM96iK 2prw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MlZMsRZn; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m7si14848409pgi.547.2018.11.11.16.12.02; Sun, 11 Nov 2018 16:12:17 -0800 (PST) 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=MlZMsRZn; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730652AbeKLIRV (ORCPT + 99 others); Mon, 12 Nov 2018 03:17:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:60680 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730599AbeKLIRT (ORCPT ); Mon, 12 Nov 2018 03:17:19 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E6AD6223B0; Sun, 11 Nov 2018 22:27:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975244; bh=HBcD7nrjT27F7Yo8fR/R2qQglW3nlmcxDe5LkV2LbGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MlZMsRZnEhhecyepRvpDGy9Jlf3e22JQ/s+L9xYeN3IqEnewnS9dPlf0yLD++EE4k iCBMwClf9Jj4/KJdu8E5IIlmyAX0pM9N/YDPFVAgWu7lVdQZpD3ZpyeTIU5yJZ6wdR W8FXCnr6h9tQXujHu1Z16+2qUTm1U13Ran4jjsgI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sanskriti Sharma , Jiri Olsa , Joe Lawrence , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.19 066/361] perf tools: Free printk string in parse_ftrace_printk() Date: Sun, 11 Nov 2018 14:16:53 -0800 Message-Id: <20181111221629.200032919@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- tools/perf/util/trace-event-parse.c | 1 + 1 file changed, 1 insertion(+) --- 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_hand printk = strdup(fmt+1); line = strtok_r(NULL, "\n", &next); tep_register_print_string(pevent, printk, addr); + free(printk); } }