Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4467636ybi; Tue, 30 Jul 2019 02:34:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxYgzxb/NIXCfxsym3FgyrTLdLwpKBhVFjDDojQeqm7R0PzhfyxTCQ9IxpvC0FGP30sRRN X-Received: by 2002:a63:d84e:: with SMTP id k14mr108468608pgj.234.1564479281020; Tue, 30 Jul 2019 02:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564479281; cv=none; d=google.com; s=arc-20160816; b=dvCARTDj7h/N4TPbn1od1ae8fOJpNXpZQqzYGBaE7Zvyvy2MjvbDoMBlXoRfIe4lAS vbWPgP/dR2wTCAYQL85gmiUVA0zKlsXDIcK411x7mRds/vuy8OjwRTPRYqm2dZix/JiZ q1my1/9nQoJmbi0B8VX3BFd946tcs4KjaAQ+8D5yRbVlDL3C9HfrwCyR/B2bfY5MvrQq TLeNNP0Y3WBdqyi2IJp1zssfWj9XeILhna9RX+qYF8hwLBs6V1oMVs9nhGyuYkJAlEEV 6RaJ/FR9tjiR3zNyGJheCbNPGsW4tMfFa2LKPi6mcLH4v8NXzRQceNltfm+/ea6w/ug4 oAEQ== 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=LxHdlVcb4O1KXI2s0LMH1tV5Z2/1LTz/F4sJ16ZyKkQ=; b=ux3B5QpmgIyPhm9Ix79c530CkKlXMPPg4KoNOX+YFNNCn8Rd91mXkbiwafDlNcXbpm 7Kwr5T4Y6PfJ/6vuUTp9eJZGZxXYLNzQIxcvsd9FUWvskHk/yfaBJIcZLweKoFUCsZph f2x31NpjCHceJMcBYcM3w0cgDL+k7XO5bJjjTdUfpCYPjrXax5msCI/aPjmgbybWbIlo x3Xia4UmTRf0udFhIl8kdV9tBWhy6+BYwAZaesidPWJhH1N8VZTbcvM7knblLmK0Lz33 BWQLjuCszlqB9pZJx20oucbJx3om1YF3gPasklFYagTyVJhAbOd/IeBqh6Ll+iMaU5lx wsiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=wWuCaQBH; 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 o8si26270217pgd.582.2019.07.30.02.34.26; Tue, 30 Jul 2019 02:34:41 -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-2018-07-02 header.b=wWuCaQBH; 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 S1730153AbfG3ADW (ORCPT + 99 others); Mon, 29 Jul 2019 20:03:22 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:36820 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730107AbfG3ADT (ORCPT ); Mon, 29 Jul 2019 20:03:19 -0400 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 x6TNx2AM162569; Tue, 30 Jul 2019 00:02:50 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-2018-07-02; bh=LxHdlVcb4O1KXI2s0LMH1tV5Z2/1LTz/F4sJ16ZyKkQ=; b=wWuCaQBHOq7JKi99Sbbr14VP+NxLit44yT9tn9aV7wXsWTr1E2brHC81EGgtjAqp8fmm QzqgFWo4qIqe28uYkJ3fYGoGYM5GfwLRisNxhMTn4ulJPdfMuANrDoky1NXgKvYFIKww wdmUpSyqWEfBV8TmflggMo8pM6BtnPyrf55JhxQP5UVDBXUgTBfnbr6k0Kp4Gp2u98Ff 3sA5cc0p9v8wobMDkWK5DL3EU+Lzysi644BRyfCwyI8s0RGFfGurRtW3zIrtgKpk8nN9 texeppMJEcSAnO/YUv1O+LQrrCkjGAW9pFX32hUQRoMYRmlxEERyw9+CQER6Z8V4khK7 Ag== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2120.oracle.com with ESMTP id 2u0f8qtpgy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Jul 2019 00:02:50 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x6TNvmPL039169; Tue, 30 Jul 2019 00:02:49 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3030.oracle.com with ESMTP id 2u0xv7th9m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 30 Jul 2019 00:02:49 +0000 Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x6U02mtD003744; Tue, 30 Jul 2019 00:02:48 GMT Received: from ca-common-hq.us.oracle.com (/10.211.9.209) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 29 Jul 2019 17:02:48 -0700 From: Divya Indi To: linux-kernel@vger.kernel.org, Steven Rostedt Cc: Divya Indi , Joe Jin , Aruna Ramakrishna , Srinivas Eeda Subject: [PATCH 4/7] tracing: Adding NULL checks Date: Mon, 29 Jul 2019 17:02:31 -0700 Message-Id: <1564444954-28685-5-git-send-email-divya.indi@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1564444954-28685-1-git-send-email-divya.indi@oracle.com> References: <1564444954-28685-1-git-send-email-divya.indi@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9333 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-1906280000 definitions=main-1907290261 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9333 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-1906280000 definitions=main-1907290261 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 --- 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 468ecc5..22bf166 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 b6b4618..99eb5f8 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -800,6 +800,8 @@ 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