Received: by 10.213.65.68 with SMTP id h4csp348220imn; Wed, 28 Mar 2018 04:56:12 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/aa1/NkOK2ky9VRNdJuU3tUGtWIauq1t544bewCCn/qz1Bj1rUE4CwaAZ/SlbHHAy8v2PI X-Received: by 2002:a17:902:7295:: with SMTP id d21-v6mr3461986pll.130.1522238172489; Wed, 28 Mar 2018 04:56:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522238172; cv=none; d=google.com; s=arc-20160816; b=pnDH+cftwayj8CAeBTsU5A5ZTnLK/F2LX7yP7FgrxqSz/UAzVDZdKO8MDuqSJh4Oes Ky3SkwNXBiekNtp3NT2c3x0M1P0UCv8rPY8RHfacxFid2sFL56xJugqBCnIqDh0eiwnN yk8wS+FtKFzgb2w2AJAI3JLtvNvQaOPjW4YtdvfYv4KMjuukLkyzgaqq0MinuiSKeyFc Z+JpTWC6i10mcgL8CEaB3IO2AhyEen/Xtjx0+rA4N8iMoQ0xfuDHIItyPMEqzsF8m4ha gqgBll8NtZKM+/nWD7q+IP3nSQzD1Kh6zEiPkzqVU2C8m5CE8qOZ+JsiurjsjC2utnzW kYFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=X93svaDcFG146oRoeY37pVcG/2IZethk3w5eCZzQNT8=; b=lfVtj2wKmmvzo0nHBtSUVaO60ufiWNy5czdO1/gixrAYUV1cRR4yAoXY5xNlhaHDS8 WbtpoDOw1zj85myr8OonzMZE2nAP1vvQ9MMWGp6+CqlRyWgPajEbF5alqnpLMMWzawnM 3MqTruiVywmlVJ+kuPZRlaRr0iUVk0yIct2nj4kIQCkBsgnrf5tc1vAQA1/gO+fVgwDs 7BuACk8facBlM3aVNIWi9DfyhjMaSq7LXifIarxbSO9ZlR5gN0KB/e+76vUUF1RNEsdS hf6/p+b4QuBr2ZYkWpvkwinzTKM9U0SHdgXoHetNN5FX073wl3U7gkxbtKa4OnjLmHcK o/jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2017-10-26 header.b=SJs80x/r; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i74si2359524pgc.262.2018.03.28.04.55.58; Wed, 28 Mar 2018 04:56:12 -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=@oracle.com header.s=corp-2017-10-26 header.b=SJs80x/r; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752620AbeC1Luf (ORCPT + 99 others); Wed, 28 Mar 2018 07:50:35 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:45080 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752364AbeC1Lua (ORCPT ); Wed, 28 Mar 2018 07:50:30 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2SBgD9a162382; Wed, 28 Mar 2018 11:49:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2017-10-26; bh=X93svaDcFG146oRoeY37pVcG/2IZethk3w5eCZzQNT8=; b=SJs80x/rxQiRe9uF26Z0mAR32PHG5nJH/eSqFYSegCan84wUfogWI9LSbOcxW+xpzMdF tcg8SILozfs8s/kyPY/3LWQGDkONfwoq2UrQMjO95Ng4zwWAYu25KSKMalkMF2XMKm5p pD+n+GBYh9PzB02HmClAUnCUx9Cp+2iqXmvLjT3yLBJqK1AKSAMRfqOwtl0CHqoZ4iks MSarwglj3EZGaaCJdyfZyEzGW5mbWkudL3iqODYW2068KvcX02JcPBjru4OScBRR6wJS LLaGVEzCfvQJW4/AE3uC8MOHcdhnSM7dkK83fc46Wyt5PYuxKFdmq/y5mLMM+j/WQVdm sw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2h0adjg0s9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Mar 2018 11:49:25 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w2SBmOrD024163 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Mar 2018 11:48:24 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w2SBmNdn011815; Wed, 28 Mar 2018 11:48:24 GMT Received: from mwanda (/197.254.35.146) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 28 Mar 2018 04:48:23 -0700 Date: Wed, 28 Mar 2018 14:48:15 +0300 From: Dan Carpenter To: Steven Rostedt , Tom Zanussi Cc: Ingo Molnar , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] tracing: Uninitialized variable in create_tracing_map_fields() Message-ID: <20180328114815.GC29050@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8845 signatures=668695 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=840 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803280121 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Smatch complains that idx can be used uninitialized when we check if (idx < 0). It has to be the first iteration through the loop and the HIST_FIELD_FL_STACKTRACE bit has to be clear and the HIST_FIELD_FL_VAR bit has to be set to reach the bug. Fixes: 30350d65ac56 ("tracing: Add variable support to hist triggers") Signed-off-by: Dan Carpenter diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 4f027642ceef..6aceee287d07 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -4411,7 +4411,7 @@ static int create_tracing_map_fields(struct hist_trigger_data *hist_data) struct tracing_map *map = hist_data->map; struct ftrace_event_field *field; struct hist_field *hist_field; - int i, idx; + int i, idx = 0; for_each_hist_field(i, hist_data) { hist_field = hist_data->fields[i];