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 49751CA0EED for ; Fri, 22 Aug 2025 09:41:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1031A10EAAF; Fri, 22 Aug 2025 09:41:01 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Jm9IdiLE"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id BCE5410EAAF for ; Fri, 22 Aug 2025 09:40:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1755855659; x=1787391659; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TdXVlHSta29BAiotJU/TYSTb59dwzDCEECq6ekRRk2k=; b=Jm9IdiLEAXaB+6HTZITlUbLozFBmp1ZA7zzf299Ng2SYn+hI9iZ3LLeP MT1NPy8WjQyp1CNwDBPKniA6+G3m7vqYTqVhW+Y3rtuwx4QdWW6MrIM7g UhqKINwaYLzPRggJ1/68KvVUsRYSPzhrwJx0xqFYp1JIryJjPkacWAKvH nXCc1JeG8bapmszXD2hMAYkulxd79tlBofNA7E9Ebgi6mXka97KUctooA hPPPsDwBCfGG5pZwnbtCp34fT2ogzswenkcaGIbm39EKEt0IzjneuwQSS Zd6HJPrhmA4hFPZNX7xa4kCFWSSRQ1qYWwb+i/uIf7xXIt45kqmeW/JMI A==; X-CSE-ConnectionGUID: zfXfpC2aQDynw40CwkNp9Q== X-CSE-MsgGUID: KsX3IAndQ4eYoXnT0TU09Q== X-IronPort-AV: E=McAfee;i="6800,10657,11529"; a="80760599" X-IronPort-AV: E=Sophos;i="6.17,309,1747724400"; d="scan'208";a="80760599" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2025 02:40:59 -0700 X-CSE-ConnectionGUID: HN1I34FnTDqeA2fF85gSKA== X-CSE-MsgGUID: bLtWT/HxSPCJVM+gUcN11A== X-ExtLoop1: 1 Received: from ncintean-mobl1.ger.corp.intel.com (HELO fedora) ([10.245.244.108]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Aug 2025 02:40:56 -0700 From: =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= To: intel-xe@lists.freedesktop.org Cc: =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Brian Welty , Rodrigo Vivi , Lucas De Marchi , stable@vger.kernel.org, Matthew Brost , Joonas Lahtinen , Jani Nikula , Maarten Lankhorst , Matthew Auld Subject: [PATCH v2 03/16] drm/xe/vm: Clear the scratch_pt pointer on error Date: Fri, 22 Aug 2025 11:40:17 +0200 Message-ID: <20250822094030.3499-4-thomas.hellstrom@linux.intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250822094030.3499-1-thomas.hellstrom@linux.intel.com> References: <20250822094030.3499-1-thomas.hellstrom@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" Avoid triggering a dereference of an error pointer on cleanup in xe_vm_free_scratch() by clearing any scratch_pt error pointer. Fixes: 06951c2ee72d ("drm/xe: Use NULL PTEs as scratch PTEs") Cc: Brian Welty Cc: Rodrigo Vivi Cc: Lucas De Marchi Cc: # v6.8+ Signed-off-by: Thomas Hellström Reviewed-by: Matthew Brost --- drivers/gpu/drm/xe/xe_vm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c index f35d69c0b4c6..529b6767caac 100644 --- a/drivers/gpu/drm/xe/xe_vm.c +++ b/drivers/gpu/drm/xe/xe_vm.c @@ -1635,8 +1635,12 @@ static int xe_vm_create_scratch(struct xe_device *xe, struct xe_tile *tile, for (i = MAX_HUGEPTE_LEVEL; i < vm->pt_root[id]->level; i++) { vm->scratch_pt[id][i] = xe_pt_create(vm, tile, i); - if (IS_ERR(vm->scratch_pt[id][i])) - return PTR_ERR(vm->scratch_pt[id][i]); + if (IS_ERR(vm->scratch_pt[id][i])) { + int err = PTR_ERR(vm->scratch_pt[id][i]); + + vm->scratch_pt[id][i] = NULL; + return err; + } xe_pt_populate_empty(tile, vm, vm->scratch_pt[id][i]); } -- 2.50.1