Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4166200pxk; Tue, 8 Sep 2020 12:22:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbgC/ziK8khFTHy9B6C3dYiUBmlGXOaASfel8tmrJkgpbcbISNWCHlJjZTCujBthcJ6s7J X-Received: by 2002:a17:907:270f:: with SMTP id w15mr28771183ejk.141.1599592951719; Tue, 08 Sep 2020 12:22:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599592951; cv=none; d=google.com; s=arc-20160816; b=bqCn7AaohtNp7vnl2SRESqjiteVxCWXHOj0JLS4DXfF3lNfPYZYqHsguxY6mMIr4zh qhyTpTTqnHrE6zoisp1oMFTQDoucM915Oi0j3B7beRkcWQ5NXg+0v6jEvrhhvwtmQJm8 ty3t+RlPnXTQqL184KUhu9TbK20gctCuVr6yN1eRkWh9bWDwvc/GoHAGruTm1x4If6vy VqP1kAShdXqf1EO7FCA191RFao3Kv/20ObqmCzfhfk3OoBSo4meNSbz7RNx1ivIVp9Pf +I15swRxvzjSJLkFhlbSTlI2vQCD5RGyfkaI0r/Yee2mRZOROyCMn4e0o8IUvKEEC11a cB4w== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=/8syP6kYeGbyoCttR8rLLMH2xY0Nom5gNj2phYHtWSs=; b=0ctn9EK2tIwd4nV5hayjNAgDXRTklq49Cc5hOcWP3AUAxRsrWss2EpXim8xTNRGdfC ADnYA3d2idzpTjWjYt3aew36Qe5dbaPnjvrdZQmPwdoTjpRwH3QbhtuT5j9P3Ew/ZjPr LFjoo/e/4w42D4pKclTInCWRFaHCCRIYQ4zraMvrlzbKVRLG7mTrD40hI13yB+OPlisl 47iCK9x/geCDB1bH1YjAHGsaEcJtQ/6LQ25YIBzNuu4Zst3JyrJ/cwqA7ZkndCOSxGY4 kaw6ms0xf4iRQNA/D26L0J3mh5SjlYa+X9rrdV40k2z7+cBLsDe6xogTlaMzZf0z6XRv vxhw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id yd16si13171778ejb.689.2020.09.08.12.22.09; Tue, 08 Sep 2020 12:22:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732001AbgIHTS0 (ORCPT + 99 others); Tue, 8 Sep 2020 15:18:26 -0400 Received: from mga02.intel.com ([134.134.136.20]:59407 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731142AbgIHQCw (ORCPT ); Tue, 8 Sep 2020 12:02:52 -0400 IronPort-SDR: po/k/mVz/rKQaNpunDFGyqwHb7oftmN3x2KIS4nbF4kaHt0gr1UPXQFvpe6SXoijBbRbG+rTUl bDB2wMf4hAtQ== X-IronPort-AV: E=McAfee;i="6000,8403,9738"; a="145860470" X-IronPort-AV: E=Sophos;i="5.76,406,1592895600"; d="scan'208";a="145860470" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2020 07:41:11 -0700 IronPort-SDR: GwGJVhQl5LsZCtYfS7A9iPjpGOoLjIqPKg8jU0lNh+QzaUUg/j/tOkU/84RoXAzvNqvUBXGq2n hbejdvwrRCjQ== X-IronPort-AV: E=Sophos;i="5.76,406,1592895600"; d="scan'208";a="480050658" Received: from dpdesmon-mobl1.amr.corp.intel.com (HELO [10.212.58.192]) ([10.212.58.192]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Sep 2020 07:41:03 -0700 Subject: Re: [PATCH] tracing: fix double free To: trix@redhat.com, rostedt@goodmis.org, mingo@redhat.com, natechancellor@gmail.com, ndesaulniers@google.com, baohong.liu@intel.com Cc: linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com References: <20200907135845.15804-1-trix@redhat.com> From: "Zanussi, Tom" Message-ID: <84df7ef3-0a36-0929-3fa9-74ab773ca12e@linux.intel.com> Date: Tue, 8 Sep 2020 09:41:01 -0500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200907135845.15804-1-trix@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tom, On 9/7/2020 8:58 AM, trix@redhat.com wrote: > From: Tom Rix > > clang static analyzer reports this problem > > trace_events_hist.c:3824:3: warning: Attempt to free > released memory > kfree(hist_data->attrs->var_defs.name[i]); > > In parse_var_defs() if there is a problem allocating > var_defs.expr, the earlier var_defs.name is freed. > This free is duplicated by free_var_defs() which frees > the rest of the list. > > Because free_var_defs() has to run anyway, remove the > second free fom parse_var_defs(). > > Fixes: 30350d65ac56 ("tracing: Add variable support to hist triggers") > Signed-off-by: Tom Rix Good catch, thanks for fixing this! Reviewed-by: Tom Zanussi > --- > kernel/trace/trace_events_hist.c | 1 - > 1 file changed, 1 deletion(-) > > diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c > index 0b933546142e..1b2ef6490229 100644 > --- a/kernel/trace/trace_events_hist.c > +++ b/kernel/trace/trace_events_hist.c > @@ -3865,7 +3865,6 @@ static int parse_var_defs(struct hist_trigger_data *hist_data) > > s = kstrdup(field_str, GFP_KERNEL); > if (!s) { > - kfree(hist_data->attrs->var_defs.name[n_vars]); > ret = -ENOMEM; > goto free; > } >