Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp577119ybi; Wed, 3 Jul 2019 01:17:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1rg3Zt5bxRP5lRPYo1y4OUFOjEdYK3eJc7anr4R8fp3f8twAhNtiAL1Ldj98VCiGqriYr X-Received: by 2002:a17:902:e40f:: with SMTP id ci15mr40957004plb.103.1562141869279; Wed, 03 Jul 2019 01:17:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562141869; cv=none; d=google.com; s=arc-20160816; b=wgMSzEjCPK4aD4/iU5Q6QV7QkJcLahytwS+8YI3VAYAf9LtEbcdPeIL+vRHxqoGAG6 Gb8t0rduxjI/mQJ3dTN5f0TeGUn5oqHBDl07x45Z+RyLnj4DeTLx2uh9Y5tDFROSFsS0 C5PaL3sr+QEantewuWged5ET4+Et0RJujXrqlTUD4klf1lgKu3S5Ru8nAHd6LXwGGple 3VNjRrTYxVPsybTeVJhDeaE38vrBs9dcj0HpadaIb0BKSIsMa9G8qlLgGyMiid89e2gY WtjduEJ/Vo/bhTZA7pHAYVGP/2QJy8Z6nMoxnTouV29YA/iZciQ+0N7xrL263K+Vu+hO VEkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=KbUJk2ldtGkFXbb/hUiSZglrGE0E+zl75r+apGMwxXc=; b=Q2TLbR8VgAmLgQJBo+vyQwOieVSy17QAUkHQ4soXnKsDtc0WimY5YAPJm0Fgk5kP9K NP1lWXBSYy8jKu95E4IRwZ21m2Slaex8V3svp6KxWPJvHZQTI30pCIXdwOaONrgBhnmV kL3G+UiDuh7roe8bXCI3Hi9lHs+ngmeIxto8+XPWlA25Syd+zrbuWL9bdcxQU3GIccfp N3ApIdlRrVrSLRTJPMacCs8Xukba8g0GWMxnys6+WdiH9tq6mLdAktgRll5CO2RMxn9I RUGbn/GYhNAWI6t5Aoxqhk++2uP0riokDfOV9VN+Jc3fiE0oP+MRLyQsmWiR43xK4omg CKAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=taHtVk2p; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v41si1722908pgn.481.2019.07.03.01.17.34; Wed, 03 Jul 2019 01:17:49 -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=@linaro.org header.s=google header.b=taHtVk2p; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727371AbfGCIRM (ORCPT + 99 others); Wed, 3 Jul 2019 04:17:12 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:40353 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727103AbfGCIRM (ORCPT ); Wed, 3 Jul 2019 04:17:12 -0400 Received: by mail-ot1-f66.google.com with SMTP id e8so1435507otl.7 for ; Wed, 03 Jul 2019 01:17:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=KbUJk2ldtGkFXbb/hUiSZglrGE0E+zl75r+apGMwxXc=; b=taHtVk2prlLVdkCLv7izJLUW8aglmKjNUhvyHAfVNVSnYnAW3untkvdgmFWHmoiuwi uQ8enVGVbsPu+lIBQi6hrm2Au6jS5v209ePxq8WxNT16IrRx4heT1SvAS+fgiHDSZWGp 7eFBC72rZ19FCVg7ZYwIBT8Ck8L5IhR/+dLEk/3fq5F50Bm5Cp0labne5B2MNjOmdkHc bzdQNCIZCMNySeqcr+VsOB9MkTA6+T36eeEAVvhXXf/hmU4lNZGVKVt74Ar8obEX9bS+ cdAIhdpiL5/KzW1J9yHW1xqM8vM340ZZYmRcSXGMjRROIQw645spS05tc0xGNMfN9wFd AOhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=KbUJk2ldtGkFXbb/hUiSZglrGE0E+zl75r+apGMwxXc=; b=G+63Ch+HSWGgPS4BDdpKR1AnAyZpUcEY+OVySylHIS149pkwUWi0ii8Ae7W9oe11GA chRL/nw4olL+Fr9jrgDU8qTi+hy22aWjBEeDXP2AbbdUUsD1ipbP8B5QcrILGRpXN4ly cuuSm3VyigJGFNP4M9wED6yKdtF/z3qKOUeZy/Jprg+kKgjRJqfAjOdP/HoqMali6EnK I3lVysEZ3y7ijE0MJRAATxsD+yNsJHCVq4uuT2r20ulniopCt5411KMQSJjx+8fl187r 7Pqz1dmXVEPD9p7CxGN1rOCoMQEqImBINHYFa0j8YGDE6g3ABxN4ngfJJpA94nkx2g5L kGWA== X-Gm-Message-State: APjAAAWG6RMroRPyCM2HC4VVKa6D3lGuYleec39DqHcz+I016BxS1St9 7oUAjJPUUD1Z7+iOE8Kcp+l9Lg== X-Received: by 2002:a9d:1718:: with SMTP id i24mr26800741ota.269.1562141831330; Wed, 03 Jul 2019 01:17:11 -0700 (PDT) Received: from leoy-ThinkPad-X240s (li964-79.members.linode.com. [45.33.10.79]) by smtp.gmail.com with ESMTPSA id d200sm554816oih.26.2019.07.03.01.17.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Jul 2019 01:17:10 -0700 (PDT) Date: Wed, 3 Jul 2019 16:16:57 +0800 From: Leo Yan To: Adrian Hunter Cc: Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Mathieu Poirier , Suzuki K Poulose , Andi Kleen , "David S. Miller" , Davidlohr Bueso , Rasmus Villemoes , Jin Yao , Song Liu , Alexios Zavras , Thomas Gleixner , Changbin Du , Eric Saint-Etienne , Konstantin Khlebnikov , Thomas Richter , Alexey Budankov , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v1 10/11] perf intel-pt: Smatch: Fix potential NULL pointer dereference Message-ID: <20190703081657.GD6852@leoy-ThinkPad-X240s> References: <20190702103420.27540-1-leo.yan@linaro.org> <20190702103420.27540-11-leo.yan@linaro.org> <20190703013553.GB6852@leoy-ThinkPad-X240s> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 03, 2019 at 08:19:19AM +0300, Adrian Hunter wrote: > On 3/07/19 4:35 AM, Leo Yan wrote: > > Hi Adrian, > > > > On Tue, Jul 02, 2019 at 02:07:40PM +0300, Adrian Hunter wrote: > >> On 2/07/19 1:34 PM, Leo Yan wrote: > >>> Based on the following report from Smatch, fix the potential > >>> NULL pointer dereference check. > >> > >> It never is NULL. Remove the NULL test if you want: > >> > >> - if (session->itrace_synth_opts && session->itrace_synth_opts->set) { > >> + if (session->itrace_synth_opts->set) { > >> > >> But blindly making changes like below is questionable. > > > > Thanks for suggestions. > > > > I checked report and script commands, as you said, both command will > > always set session->itrace_synth_opts. For these two commands, we can > > safely remove the NULL test. > > > > Because perf tool contains many sub commands, so I don't have much > > confidence it's very safe to remove the NULL test for all cases; e.g. > > there have cases which will process aux trace buffer but without > > itrace options; for this case, session->itrace_synth_opts might be NULL. > > > > For either way (remove NULL test or keep NULL test), I don't want to > > introduce regression and extra efforts by my patch. So want to double > > confirm with you for this :) > > Yes, intel_pt_process_auxtrace_info() only gets called if a tool sets up the > tools->auxtrace_info() callback. The tools that do that also set > session->itrace_synth_opts. Yes. I also checked the another case for 'perf inject', just as you said, it sets both inject->tool.auxtrace_info and session->itrace_synth_opts if we use 'itrace' option. So it's safe to remove the NULL test for session->itrace_synth_opts. Will follow your suggestion for new patches. Thanks a lot for confirmation and suggestions. Thanks, Leo Yan