Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3805391ybi; Mon, 29 Jul 2019 13:00:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwLMbSl2FXjgYGbAR44C+t1oP9CatzxkVHIZPKRFlaH31AiOoFlPB0TWSI7d4HJp4ybQRo X-Received: by 2002:a63:2364:: with SMTP id u36mr102344648pgm.449.1564430401410; Mon, 29 Jul 2019 13:00:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430401; cv=none; d=google.com; s=arc-20160816; b=zmnOxlFHLDSTUFA33WxFiEVwHvtgCkCzP1NjtIZ95dRozCkZvur9tWL3xzZaFE/7SF qJNz/S0Zvn+zSKSiHdiVfD+kzsH9Nc5P5C5WBMyYrVFBUZygfjE7jdejBNUms9854qW2 yqAIdbXkzbt18ws3ZJSjc/VWf5UL45qHeYgWQ8xv6x9hJFU/HJ4M4AJX+FF6CQs5GUBf eM7PnOvQgYO4LeDR5tqmV11Fq262jCwE6f3X6/XTjiUYq2tzUWIPVgBHNUh04IA1JBow EAnpvG/oM8Q3Fo1rL8zxMHJ/KbDYwfFjNTV22Ed9sjZo4Ra+OC5g5hNweGR8n5sBdfsd iZdA== 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=3eDkVhGKk/QqVw8UV9+N0WNNhdT4YRcZh0XwGum2ehg=; b=vgPKl6cm4OarYvNQBJIHd9eoH0SPPlhpU3GIPZrsTOeReZTUEmEiol8/35aKMh2nI7 6A/HfX2Cer9x8f3sTAdQYs4r5Uk9tHFlJqLjCpu7O+bEHDh+5pFnHfKV2CBARhP22UL7 SpGeG40jrRhzG6mA4TNJN0biJwXXqFXpzGGyktP7sm/cYA008CWp92bYmjroVF0BbGio NuaEGy7z0TTUNRfGGrzz5YkZTG4dlekBE+TgMmAprOxnqgbM4m5axJ4WCpURdnxIlNlB O67oarAfeBXJqZ6/6pfKiDf8NQQR5AcIm+zSE2BF6ZmjkTAb8V78seHURCFtcGFHzLkm B3Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a8dBa6rG; 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 u20si25368918plq.421.2019.07.29.12.59.46; Mon, 29 Jul 2019 13:00:01 -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=a8dBa6rG; 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 S2390897AbfG2Txc (ORCPT + 99 others); Mon, 29 Jul 2019 15:53:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:45278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403963AbfG2TxK (ORCPT ); Mon, 29 Jul 2019 15:53:10 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 BEFF52184B; Mon, 29 Jul 2019 19:53:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429989; bh=IuQ35tiPs50YWvIuyyRt+BzuJkrV/5QXgKWzYtVS5ow=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a8dBa6rG6S8/W45Sy8UArsLDnox7OEVntuvzhtrcakpHiy/uQDVVCo7eFSvdSWw70 VswURLzo40U3ZS1KPEssXS3NNeH1oG0v2BjT06D8YuwuqNi/HK3SF4CkbISiSqP8LK 6hBB9NUkOHZr4czlzbNMxmQ83IF0arA1mV0otW/8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Leo Yan , Jiri Olsa , 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 , Namhyung Kim , Peter Zijlstra , Rasmus Villemoes , Song Liu , Suzuki Poulouse , Thomas Gleixner , Thomas Richter , linux-arm-kernel@lists.infradead.org, Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 5.2 123/215] perf trace: Fix potential NULL pointer dereference found by the smatch tool Date: Mon, 29 Jul 2019 21:21:59 +0200 Message-Id: <20190729190800.504666262@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit 7a6d49dc8cad8fa1f3d63994102af8f9ae9c859f ] 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 Signed-off-by: Sasha Levin --- tools/perf/builtin-trace.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 52fadc858ef0..909e68545bb8 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -997,10 +997,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; } -- 2.20.1