From patchwork Tue Jul 9 18:31:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaldo Carvalho de Melo X-Patchwork-Id: 168758 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp8896352ilk; Tue, 9 Jul 2019 11:32:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPHLHKml/yViyV4k2RqzH8V+aOi97PJc5apBYY+ZMu/wx3+SUSIMz5LbbsTBlhmhQ7AHgk X-Received: by 2002:a63:5212:: with SMTP id g18mr31018034pgb.387.1562697131813; Tue, 09 Jul 2019 11:32:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562697131; cv=none; d=google.com; s=arc-20160816; b=01TTC51iERbr6w0wUhGtr3ubnxcLISF4n8Kr8W1x+67wEq4/M/SPPWFuDYP9Z9ZvaB SreAGMCIKxPOrtLCuV1YVf6z8oUOi94itVPp7qprfsWcvExjqT2lq79bV9Gbd7Fhv3HX skeO7i7TLn6aq8h3xQtIT1h6ffYWdJGEUUKglynROWqar3EUrIDreQLmo7S6DYAxmzt6 u+ewYOkBuXuw6UTdx3VPkgsz7soQXP9CTcUGvnziSpQhAtdhiy0Uo7cmrfkVi0xBjwQM Ng6NHqJUSdQOZBOHZSca/1NCRQp90DPFR0CoIGLvMjMCuSVqd9I4QUvI8aN4TQvTK6Ru n1tQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yThV/wsDbOO7z0W8p5jy900zA1BoiaC/u+pr+N5bygA=; b=LwMKaKWcmbmrUop2KdWA17Qq3CUXVrIufvfeOTiPHlKZ2sc6AfzTO+zh1+haLSf/DL uIKtXgfzDzIChcmd8+bNgxVISCHVDd7xmmQc+kHbrYTpI3fGOhNpyjCn9keaACiYRQLb UlbN9LJZT8cFQHmpaOZW13dBgnv90Yi5fzL0TwcP9cu7xGSpBqstbPYJ+Rtazf/VvjX0 zqx8n7feSheYPf/HwTqgTcV9Ib8vMsEDqcGQbqYY3etHpBNxtbMnkH68mRGqi2h7NSex wz1SWW6EgG/woIKFcttFjyNukssf2enirlHojdXOlODEVzzXw32qWEP1xX8amytpmjwH xB2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=R5NqjC4s; 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 u185si20804361pgd.561.2019.07.09.11.32.11; Tue, 09 Jul 2019 11:32:11 -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=R5NqjC4s; 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 S1729079AbfGIScK (ORCPT + 30 others); Tue, 9 Jul 2019 14:32:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:53464 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726592AbfGIScJ (ORCPT ); Tue, 9 Jul 2019 14:32:09 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.35.11]) (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 CFCAC2087F; Tue, 9 Jul 2019 18:32:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562697128; bh=uKY1upGstB9eyiC2tvMjOQrnpwH5zhKS9cvZBMmwlRY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R5NqjC4skuB80xSqY6Wwp1WwLiCweXwZ4voKnG+hZZIIGLatgkiHk+63fQN4xEqr8 SvuRJwGK0s2OPCDFsud6JvVO/9KhewPXZZLlxe6R8inbDBGyOn/YUFfL1UrrWJ82oC /KSRamxD4VurvzRcHPHPaEYLPpkeV2JjNtjxj8Q4= From: Arnaldo Carvalho de Melo To: Ingo Molnar , Thomas Gleixner Cc: Jiri Olsa , Namhyung Kim , Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Leo Yan , Adrian Hunter , Alexander Shishkin , Alexey Budankov , Alexios Zavras , Andi Kleen , Changbin Du , "David S . Miller" , Davidlohr Bueso , Eric Saint-Etienne , Jin Yao , Konstantin Khlebnikov , Mathieu Poirier , Peter Zijlstra , Rasmus Villemoes , Song Liu , Suzuki Poulouse , Thomas Richter , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo Subject: [PATCH 05/25] perf trace: Fix potential NULL pointer dereference found by the smatch tool Date: Tue, 9 Jul 2019 15:31:06 -0300 Message-Id: <20190709183126.30257-6-acme@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190709183126.30257-1-acme@kernel.org> References: <20190709183126.30257-1-acme@kernel.org> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leo Yan Based on the following report from Smatch, fix the potential NULL pointer dereference check. tools/perf/builtin-trace.c:1044 thread_trace__new() error: we previously assumed 'ttrace' could be null (see line 1041). tools/perf/builtin-trace.c 1037 static struct thread_trace *thread_trace__new(void) 1038 { 1039 struct thread_trace *ttrace = zalloc(sizeof(struct thread_trace)); 1040 1041 if (ttrace) 1042 ttrace->files.max = -1; 1043 1044 ttrace->syscall_stats = intlist__new(NULL); ^^^^^^^^ 1045 1046 return ttrace; 1047 } Signed-off-by: Leo Yan Acked-by: Jiri Olsa Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Alexey Budankov Cc: Alexios Zavras Cc: Andi Kleen Cc: Changbin Du Cc: David S. Miller Cc: Davidlohr Bueso Cc: Eric Saint-Etienne Cc: Jin Yao Cc: Konstantin Khlebnikov Cc: Mathieu Poirier Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Rasmus Villemoes Cc: Song Liu Cc: Suzuki Poulouse Cc: Thomas Gleixner Cc: Thomas Richter Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/20190702103420.27540-6-leo.yan@linaro.org [ Just made it look like other tools/perf constructors, same end result ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-trace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.21.0 diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index d0eb7224dd36..e3fc9062f136 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -1038,10 +1038,10 @@ static struct thread_trace *thread_trace__new(void) { struct thread_trace *ttrace = zalloc(sizeof(struct thread_trace)); - if (ttrace) + if (ttrace) { ttrace->files.max = -1; - - ttrace->syscall_stats = intlist__new(NULL); + ttrace->syscall_stats = intlist__new(NULL); + } return ttrace; }