From patchwork Fri Oct 27 14:07:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harshit Mogalapalli X-Patchwork-Id: 158944 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp630211vqb; Fri, 27 Oct 2023 07:08:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGx7zhErlqTtsliwYLdn5lge22cA8MMJWTWd0PUgEOUqcPUPzy48H7pJytHZHn6nuMNSZFQ X-Received: by 2002:a1f:2788:0:b0:48d:11d1:9feb with SMTP id n130-20020a1f2788000000b0048d11d19febmr1686418vkn.8.1698415688867; Fri, 27 Oct 2023 07:08:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698415688; cv=none; d=google.com; s=arc-20160816; b=whd5vefLUyOF3pkj3j0jGn4eNp6oDo80eb5IA0IbmNbo1ufw/lQctrrn4qinXpAKBy yBi6kM6+Ojo9GoY1hkBKMlSVrOoSe7BRUf8no9kQFi2vYUqWXJN7kgAEsopuWHX0cych fmuCZHJVqUq5On5srIm7UhWeezRyXqOGs1nlCV1UusSetATN+qhaMtNssYzpG7ZemBqP V2iyz5W0rwYXfmbITGbR143BFI+TJgil9HyYEjKtzbkhZOclWMhceHLDZzUrojKPQgtS 3k45FIZSFOsgZl4/qf62zMBjT9SY2j4fdms91UfMqb6MXJ1brFvy/tMWOdZdtRdDmwdz OpTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=qegBKtGW+YBLRz6D1T17k35VpwmQBPQSk8faL/IL4fg=; fh=GWZr6nJ7/tgXF+y58lcBq9MMz2YElPX3K9Z/hF1+IMY=; b=Hc30nEXh59QBrA7Aoupd9ir1eEQeD9EFlG9WWJwPmDvM4JY24Vni4H2yT7vyRtQdZ8 MNAI7sxxCJIWkeE2rkDaY5k/IsxeaH2/v+cdIOvXQRWSfZWJCCu9YfSxBEUN6ZYaFqAe CpNt+mzcpMgVFj8PKz+lMkZ2I7aRaXJbCUsPESqEfdsAs9ck59wa49y+uWODhDRdyvX0 GKMCFWkLmN/yrfloN4OJObXwQy1lT9Nte2QZv4ogKFDVERPzTuZcDNj9Dpkxd0qCAHcn AgdtY09g3FA3Caik9Bvmxo94TXK6dEoSqzF/bolNgrKGdPreO0Np6VVtJ8erj/sPU3T9 AWbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=JP8JwkR4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id l191-20020a1f25c8000000b00495b9a266dasi215985vkl.168.2023.10.27.07.08.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 07:08:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2023-03-30 header.b=JP8JwkR4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 4CBA18332E9E; Fri, 27 Oct 2023 07:07:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346052AbjJ0OHp (ORCPT + 25 others); Fri, 27 Oct 2023 10:07:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345517AbjJ0OHo (ORCPT ); Fri, 27 Oct 2023 10:07:44 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CBAED6; Fri, 27 Oct 2023 07:07:42 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39RDUrNi003793; Fri, 27 Oct 2023 14:07:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2023-03-30; bh=qegBKtGW+YBLRz6D1T17k35VpwmQBPQSk8faL/IL4fg=; b=JP8JwkR42KWSh5llMK3M7lEJxF2RZs9AHLFsI73E0gU1olZWnfGIlv6v9e8nBABsaVny +U4OBKrZdWWrLBTq6R37ax2NEuXaouMYQBLGdB+hro2WwdfZHgOuCQUUCnBjnyD6B6uc MBQTA+sTPijjwikOUlLZumjsOYE5qjj9B+wEi8Mxcw3Jbj6JpWVVY6oF47yAX3sdBQCL JJlRi7GmXlxz7c7LM7f/iYI1nLn0fEl3IZmnNBSAwYecHf+dRb/Vg7ZXeEUj4Zz1HYda mguQvQELTtFoUyVF4t+gpW/il1J24gtG4vgzm3UJNSQg5KjvL/bWr1RTws/G3eB32jch RQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tywtb9na8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 27 Oct 2023 14:07:35 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 39RDU6Js009260; Fri, 27 Oct 2023 14:07:34 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3tywqjsvx0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 27 Oct 2023 14:07:34 +0000 Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 39RE7X5G024280; Fri, 27 Oct 2023 14:07:33 GMT Received: from ca-dev112.us.oracle.com (ca-dev112.us.oracle.com [10.129.136.47]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTP id 3tywqjsvwf-1; Fri, 27 Oct 2023 14:07:33 +0000 From: Harshit Mogalapalli To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , Umesh Nerlige Ramappa , Lionel Landwerlin , Matt Roper , Andrzej Hajda , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: dan.carpenter@linaro.org, kernel-janitors@vger.kernel.org, error27@gmail.com, harshit.m.mogalapalli@oracle.com Subject: [PATCH] i915/perf: Fix NULL deref bugs with drm_dbg() calls Date: Fri, 27 Oct 2023 07:07:28 -0700 Message-ID: <20231027140729.2505993-1-harshit.m.mogalapalli@oracle.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-27_12,2023-10-27_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 suspectscore=0 adultscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2310270122 X-Proofpoint-ORIG-GUID: 4GRjFS4CGswat8B1YuhYes0lrVZjnjI_ X-Proofpoint-GUID: 4GRjFS4CGswat8B1YuhYes0lrVZjnjI_ X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 27 Oct 2023 07:07:58 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780917929274286146 X-GMAIL-MSGID: 1780917929274286146 When i915 perf interface is not available dereferencing it will lead to NULL dereferences. Fix this by using DRM_DEBUG() which the scenario before the commit in the Fixes tag. Fixes: 2fec539112e8 ("i915/perf: Replace DRM_DEBUG with driver specific drm_dbg call") Signed-off-by: Harshit Mogalapalli Reviewed-by: Andrzej Hajda --- This is found using smatch(static analysis tool), only compile tested. --- drivers/gpu/drm/i915/i915_perf.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c index 2f3ecd7d4804..bb48c96b7950 100644 --- a/drivers/gpu/drm/i915/i915_perf.c +++ b/drivers/gpu/drm/i915/i915_perf.c @@ -4228,8 +4228,7 @@ int i915_perf_open_ioctl(struct drm_device *dev, void *data, int ret; if (!perf->i915) { - drm_dbg(&perf->i915->drm, - "i915 perf interface not available for this system\n"); + DRM_DEBUG("i915 perf interface not available for this system\n"); return -ENOTSUPP; } @@ -4608,8 +4607,7 @@ int i915_perf_add_config_ioctl(struct drm_device *dev, void *data, int err, id; if (!perf->i915) { - drm_dbg(&perf->i915->drm, - "i915 perf interface not available for this system\n"); + DRM_DEBUG("i915 perf interface not available for this system\n"); return -ENOTSUPP; } @@ -4774,8 +4772,7 @@ int i915_perf_remove_config_ioctl(struct drm_device *dev, void *data, int ret; if (!perf->i915) { - drm_dbg(&perf->i915->drm, - "i915 perf interface not available for this system\n"); + DRM_DEBUG("i915 perf interface not available for this system\n"); return -ENOTSUPP; }