From patchwork Fri Dec 10 04:40:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Harrison X-Patchwork-Id: 12668659 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 E01B7C433F5 for ; Fri, 10 Dec 2021 04:40:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D220810E287; Fri, 10 Dec 2021 04:40:27 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0BD4110E1FE; Fri, 10 Dec 2021 04:40:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1639111225; x=1670647225; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=xMg3tPA59DOtQqJEklYu2alnKM8usalIjjnJFTh/VxQ=; b=G7D6vcVFLcHWk7u2oEngy4bVjZvqv9KsySWC17wmy3fqvo9lAn1MQfli /CY/PJjR31/siSeKEfRYxOmAe9qSsF0BWIr/6bof+8SHEU3e2IEYCJP5N YD72anBCfdtAQAR4o4lsZVdwdfymBQQhbtACf9weOHukdl/8Yr8Ey97xA 2rKx9f8QNaXHxq5tx2wd6uhLV/IaADtEAabqobQD56V0vvg+LR7uKdjvH GOJNnyJ4Mk3f0wH0bCz0RaMGed+MOTO1qksNekgGzMhCOKIl6nE1yl27B uEhFPSvJGLZL0TV6F2jAw4rEVxiuTT7YsKixcttE9lAP6QKIFT7xJ45t6 w==; X-IronPort-AV: E=McAfee;i="6200,9189,10193"; a="218294570" X-IronPort-AV: E=Sophos;i="5.88,194,1635231600"; d="scan'208";a="218294570" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Dec 2021 20:40:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,194,1635231600"; d="scan'208";a="480606807" Received: from relo-linux-5.jf.intel.com ([10.165.21.134]) by orsmga002.jf.intel.com with ESMTP; 09 Dec 2021 20:40:23 -0800 From: John.C.Harrison@Intel.com To: Intel-GFX@Lists.FreeDesktop.Org Subject: [PATCH 4/4] drm/i915/guc: Don't go bang in GuC log if no GuC Date: Thu, 9 Dec 2021 20:40:22 -0800 Message-Id: <20211210044022.1842938-5-John.C.Harrison@Intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211210044022.1842938-1-John.C.Harrison@Intel.com> References: <20211210044022.1842938-1-John.C.Harrison@Intel.com> MIME-Version: 1.0 Organization: Intel Corporation (UK) Ltd. - Co. Reg. #1134945 - Pipers Way, Swindon SN3 1RJ X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lucas De Marchi , John Harrison , DRI-Devel@Lists.FreeDesktop.Org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: John Harrison If the GuC has failed to load for any reason and then the user pokes the debugfs GuC log interface, a BUG and/or null pointer deref can occur. Don't let that happen. Signed-off-by: John Harrison Reviewed-by: Lucas De Marchi --- drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c index da7dd099fd93..140896bb988b 100644 --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c @@ -79,7 +79,7 @@ static int guc_log_level_get(void *data, u64 *val) { struct intel_guc_log *log = data; - if (!intel_guc_is_used(log_to_guc(log))) + if (!log->vma) return -ENODEV; *val = intel_guc_log_get_level(log); @@ -91,7 +91,7 @@ static int guc_log_level_set(void *data, u64 val) { struct intel_guc_log *log = data; - if (!intel_guc_is_used(log_to_guc(log))) + if (!log->vma) return -ENODEV; return intel_guc_log_set_level(log, val);