Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2368835ybc; Wed, 13 Nov 2019 13:21:51 -0800 (PST) X-Google-Smtp-Source: APXvYqx1ksBiXEf8quAd5oEGNZOsPqb2ldfymNcF9PNxMkzc8rH4vgZLBZwlyk/0LJ34FKe0br6L X-Received: by 2002:a17:906:4019:: with SMTP id v25mr5118823ejj.11.1573680111657; Wed, 13 Nov 2019 13:21:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573680111; cv=none; d=google.com; s=arc-20160816; b=C4Z106fn5lyY9jBIpQPuEz3Ynh0fbEdQiC/d+DK+O1T5FfUr8Y4WKGp8SfyY/ELgo9 EoPmhZjaVDmsQwQ2T2WIlDJTNeSgWAOZ1ILV2zu96oSaiPR7LdwYlKW/CmDudHpTYLux iHo7TgA+q25Zg0BQ7EVHIb3KWwJt6sMmKx5JRILSVkmflh11X2J/yuhONF0thIfWvJFn s4Sr4RoDPCVtLt50VrX+uJK1xwZIB6248sc1aogBr7SAbxG8biqnNPZEfgFKIqdvuRRS LeIcRXZd/sZIcdDPBCbnGu/GQx9P85GuXgLRSyAw1PfumNimHawLLvmMeDNVgLAAmTFM HyBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=goe3Oz3XbeEdnM9JNThocouqkZpcuLkH3OaUb+z/k6U=; b=O2LRatrGR2efF82Pl7XAGLKzdttjdW9jwI0NUFYUHAEtoTAwK3VBj7y7FTtMsXP6ct lKOXNZCGNt546JPh+wX4R847Usp4K/Mp+IVc5k03Ry2s4govxI8Ajw7hX4TmXztfrBr8 GlxmOgnj+HP0T9833Zfm5RIQiiurSU7ArmCivIKzIOLUe80a/i5LONTBxlgVs7rrKB1n NJqOw84660ELBJEt3o1Uz4CsJdMm0GyrUSMwuWem8jGY6hmzn4WRjnts3XJaX9RZ5EGF RLuyOxZtCOkE7nB4I9MBx8rsktm1TMVtIFkKLEqK0ibHUuAk5EfHQ3o2H1ZvK0C5PEN/ K1SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=L5VWtwMC; 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 x17si1986674ejs.178.2019.11.13.13.21.26; Wed, 13 Nov 2019 13:21:51 -0800 (PST) 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-2019-08-05 header.b=L5VWtwMC; 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 S1727064AbfKMVRk (ORCPT + 99 others); Wed, 13 Nov 2019 16:17:40 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:37610 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726162AbfKMVR2 (ORCPT ); Wed, 13 Nov 2019 16:17:28 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xADL3xPa034915; Wed, 13 Nov 2019 21:17:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2019-08-05; bh=goe3Oz3XbeEdnM9JNThocouqkZpcuLkH3OaUb+z/k6U=; b=L5VWtwMC4bAiqe2qAT4mh4r2VrMdY2qFIg49c/7R/jThlxlsVo91fQbxA6GwIZDLofzl 8qr7/c1QsGVjnasU8dJBZujd4zrK67w2OVs4NFfgw7MtBqfGNXKvbY46ubzp1uiVzH2s 0nRKaOAmAa5GKD59ozj3rDCbBPq2SM7cjFhqa6yl2gGCP+lAFIHmQCUkQe5T4M/b8DxF OjunwY9DYz/DcQt/99LRFlw5iqFH97VOQYRS+vesgnZC0KZHVY5iJW3K7f6feTaEq18I hIeKoWvjDEZocd9NS4vZanttNr1TlL9CCLhoyOVcALxa1UbCr3PKulcOpbjpM+tNrRyY gQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2120.oracle.com with ESMTP id 2w5p3qy6b6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Nov 2019 21:17:01 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xADL3o0X060090; Wed, 13 Nov 2019 21:17:00 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 2w8ng4n53y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 13 Nov 2019 21:17:00 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id xADLGxC8017774; Wed, 13 Nov 2019 21:16:59 GMT Received: from ca-common-hq.us.oracle.com (/10.211.9.209) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 13 Nov 2019 13:16:59 -0800 From: Divya Indi To: Steven Rostedt , linux-kernel@vger.kernel.org Cc: Divya Indi , Aruna Ramakrishna , Srinivas Eeda , Joe Jin , Manjunath Patil Subject: [PATCH 3/5] tracing: Adding NULL checks Date: Wed, 13 Nov 2019 13:16:00 -0800 Message-Id: <1573679762-7774-4-git-send-email-divya.indi@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573679762-7774-3-git-send-email-divya.indi@oracle.com> References: <1573679762-7774-1-git-send-email-divya.indi@oracle.com> <1573679762-7774-2-git-send-email-divya.indi@oracle.com> <1573679762-7774-3-git-send-email-divya.indi@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9440 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1910280000 definitions=main-1911130175 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9440 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1910280000 definitions=main-1911130175 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As part of commit f45d1225adb0 ("tracing: Kernel access to Ftrace instances") we exported certain functions. Here, we are adding some additional NULL checks to ensure safe usage by users of these APIs. Signed-off-by: Divya Indi Reviewed-by: Aruna Ramakrishna Reviewed-by: Manjunath Patil --- kernel/trace/trace.c | 3 +++ kernel/trace/trace_events.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index bff967f..e0faf81 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -3205,6 +3205,9 @@ int trace_array_printk(struct trace_array *tr, if (!(global_trace.trace_flags & TRACE_ITER_PRINTK)) return 0; + if (!tr) + return -ENOENT; + va_start(ap, fmt); ret = trace_array_vprintk(tr, ip, fmt, ap); va_end(ap); diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 0ce3db6..2621995 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -800,6 +800,8 @@ static int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set) char *event = NULL, *sub = NULL, *match; int ret; + if (!tr) + return -ENOENT; /* * The buf format can be : * *: means any event by that name. -- 1.8.3.1