Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1044959AbdDWKdk (ORCPT ); Sun, 23 Apr 2017 06:33:40 -0400 Received: from mx.kolabnow.com ([95.128.36.1]:28240 "EHLO mx-out02.mykolab.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1044882AbdDWKdT (ORCPT ); Sun, 23 Apr 2017 06:33:19 -0400 X-Spam-Flag: NO X-Spam-Score: -2.9 From: Federico Vaga To: Steven Rostedt Cc: LKML , Federico Vaga Subject: [PATCH 5/5] trace-cmd: BUG fix malloc() pointer validation Date: Sun, 23 Apr 2017 12:22:58 +0200 Message-Id: <20170423102258.21609-6-federico.vaga@vaga.pv.it> In-Reply-To: <20170423102258.21609-1-federico.vaga@vaga.pv.it> References: <20170423102258.21609-1-federico.vaga@vaga.pv.it> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 700 Lines: 26 To reproduce the bug mkdir /sys/kernel/debug/tracing/instances/test ./trace-cmd show -B test -s -f Failed to allocate instance path snapshot Signed-off-by: Federico Vaga --- trace-cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/trace-cmd.c b/trace-cmd.c index a05df92..320229e 100644 --- a/trace-cmd.c +++ b/trace-cmd.c @@ -616,7 +616,7 @@ int main (int argc, char **argv) if (buffer) { path = malloc(strlen(buffer) + strlen("instances//") + strlen(file) + 1); - if (path) + if (!path) die("Failed to allocate instance path %s", file); sprintf(path, "instances/%s/%s", buffer, file); file = path; -- 2.9.3