From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9A092C25B47 for ; Fri, 27 Oct 2023 17:38:34 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6AF9310EA22; Fri, 27 Oct 2023 17:38:30 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1F76010EA20; Fri, 27 Oct 2023 17:38:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698428308; x=1729964308; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=5JgsC4GZg9gDVZXuMx2csQQc1LKj5KoYBp4nu6PMc0Y=; b=N3PIu6ikfoDH1XfR/BADhPVUjFGLFoIIrbrPglsUw837oRQBmaQJ5E+I Ba1hyJxgsUrJoV6RvvErZN/7wX+75JKwFPy9MWm3M+LpFAL+jHbX6GzUO DhxHkRHQ1gVZnryyul2g/miOOvn4q7zoN59y7+KqmWmiA2yxmljkonBBU kRj4V+8JmlKMvjtwzshB6Cfu/NGkbJ/kDc5x4v3bQHofzDJaAcbUqgG8N +EY5kvDQIINAgl75U0cUyf3uma10p+uHR4iIijETCY4AagNP5fQFUZreJ HpsLQ/7T0+KR9DOjR3Uy8lObXw+H8PvWGX97cjFst+NNXuMJz6xkUCNop A==; X-IronPort-AV: E=McAfee;i="6600,9927,10876"; a="378188584" X-IronPort-AV: E=Sophos;i="6.03,256,1694761200"; d="scan'208";a="378188584" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2023 10:38:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10876"; a="788862211" X-IronPort-AV: E=Sophos;i="6.03,256,1694761200"; d="scan'208";a="788862211" Received: from dhanlon-mobl1.ger.corp.intel.com (HELO [10.213.221.114]) ([10.213.221.114]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2023 10:38:23 -0700 Message-ID: <29c2bf2b-82b1-457d-ba42-29b0b30ecf32@linux.intel.com> Date: Fri, 27 Oct 2023 18:38:21 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Harshit Mogalapalli , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , Andrzej Hajda , Umesh Nerlige Ramappa , Matt Roper , Lionel Landwerlin , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20231027172822.2753059-1-harshit.m.mogalapalli@oracle.com> From: Tvrtko Ursulin Organization: Intel Corporation UK Plc In-Reply-To: <20231027172822.2753059-1-harshit.m.mogalapalli@oracle.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Intel-gfx] [PATCH v2] i915/perf: Fix NULL deref bugs with drm_dbg() calls X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kernel-janitors@vger.kernel.org, error27@gmail.com, dan.carpenter@linaro.org, Tvrtko Ursulin Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On 27/10/2023 18:28, Harshit Mogalapalli wrote: > When i915 perf interface is not available dereferencing it will lead to > NULL dereferences. > > As returning -ENOTSUPP is pretty clear return when perf interface is not > available. > > Fixes: 2fec539112e8 ("i915/perf: Replace DRM_DEBUG with driver specific drm_dbg call") > Suggested-by: Tvrtko Ursulin > Signed-off-by: Harshit Mogalapalli > --- > v1 --> v2: Remove the debug calls as they don't add much value and > -ENOTSUPP is a good enough return value. > --- > drivers/gpu/drm/i915/i915_perf.c | 15 +++------------ > 1 file changed, 3 insertions(+), 12 deletions(-) > > diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c > index 2f3ecd7d4804..7b1c8de2f9cb 100644 > --- a/drivers/gpu/drm/i915/i915_perf.c > +++ b/drivers/gpu/drm/i915/i915_perf.c > @@ -4227,11 +4227,8 @@ int i915_perf_open_ioctl(struct drm_device *dev, void *data, > u32 known_open_flags; > int ret; > > - if (!perf->i915) { > - drm_dbg(&perf->i915->drm, > - "i915 perf interface not available for this system\n"); > + if (!perf->i915) > return -ENOTSUPP; > - } > > known_open_flags = I915_PERF_FLAG_FD_CLOEXEC | > I915_PERF_FLAG_FD_NONBLOCK | > @@ -4607,11 +4604,8 @@ int i915_perf_add_config_ioctl(struct drm_device *dev, void *data, > struct i915_oa_reg *regs; > int err, id; > > - if (!perf->i915) { > - drm_dbg(&perf->i915->drm, > - "i915 perf interface not available for this system\n"); > + if (!perf->i915) > return -ENOTSUPP; > - } > > if (!perf->metrics_kobj) { > drm_dbg(&perf->i915->drm, > @@ -4773,11 +4767,8 @@ int i915_perf_remove_config_ioctl(struct drm_device *dev, void *data, > struct i915_oa_config *oa_config; > int ret; > > - if (!perf->i915) { > - drm_dbg(&perf->i915->drm, > - "i915 perf interface not available for this system\n"); > + if (!perf->i915) > return -ENOTSUPP; > - } > > if (i915_perf_stream_paranoid && !perfmon_capable()) { > drm_dbg(&perf->i915->drm, Thanks for re-spinning it so quickly! LGTM. Reviewed-by: Tvrtko Ursulin Regards, Tvrtko