Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2393011lqp; Sun, 24 Mar 2024 17:28:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVTL4E37b9cwvuQIifL5xiy4vu/kROhZppPCps7wxPJJTDwoF1q8L6QbaEBe2L63iwQ9nhlx6xtGPMuTEDT2JJJmBPUodsOqw9LPtFLMQ== X-Google-Smtp-Source: AGHT+IF1dcx4i1MyiQLJ9jHKUirj1PtUTx+O7eFyhMdHCS85UD7DH9pNEYaeehe1JpYjpdfwh/oy X-Received: by 2002:a17:906:ca0f:b0:a47:1fe8:9825 with SMTP id jt15-20020a170906ca0f00b00a471fe89825mr3640365ejb.32.1711326530336; Sun, 24 Mar 2024 17:28:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711326530; cv=pass; d=google.com; s=arc-20160816; b=jZHCjYJNJwXfbIAgXUr0QkGEJLhbcjCzpFoFcqU7bcubY5arXSYr2jVaGBYspm5XE3 DbZweWpicBMJs533/0g6WaCCmX7e/18hLZ5XiEfaJX8+4IiOhK1s1Q4ZaDWF35otP/VJ jtUTATU8LgUxfVMddT7AQdO9VJTjWl7QXnVovdgVWgAOgV0iMHeTvb/Xt7jXTROMR4ib JP7zpjOoAz9eyy+UEobMTTI3oNNxf7Qobe2KjS/+HHWUvEpcq+LzVzrp19ru5ffmBVco FxMrrFf2pbcKedNVdJC4gw5niIXL7K3v2vts4lkX0ZwSwSRm0EOmo9fmVtadmm8UKBJX 0tfw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JvLfpltorWvS8BGLe1sXoVwfDGZLU0vbPaGtdlVo4Fc=; fh=w424Ip+9qz8bLhdTC9B3dxHPgd4BN8JqoBF+cjEalqw=; b=mc3/7DAmXalemZ1fv+8PI8I91ZPRVrgBqfskEuZwrZQYaff57odU5oY3/IUMo/nrHL q/JvIYlJ9r4J1YZ21QlbsA22jn3KM3eiZqbvOSd1RZmxsgtc4o+djKwcnXytOXb1taGR fAlzk9xthdJNCzFrwkmp8DD6R3517ieOCMdVA4+PLRmQYygOw5nE8S66OYoVzkqAKdBM NIRLHnglkrrZfqztaRzwBHbkEy53kbZ36t56qbqFqp6dkdHJQnL0eaWlEdc3fofZ/Svt ivMYyjRnG1VyRC83F3JSUin/iGk2lY/ggJDNMmsQnoJBVDTtODl1ihPVYiw33gw0GRmx 347A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K9iS4LRa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113401-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113401-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i26-20020a1709061cda00b00a462712f307si2091383ejh.1013.2024.03.24.17.28.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 17:28:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-113401-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K9iS4LRa; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-113401-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-113401-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 251E01F24C4C for ; Mon, 25 Mar 2024 00:27:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E07D7139CFF; Sun, 24 Mar 2024 22:43:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="K9iS4LRa" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8B906F506; Sun, 24 Mar 2024 22:43:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320203; cv=none; b=hdh7vBe1QaB5cir8iqM0xFhIng6KM8VchDStU5LwRJpRmo2QDCcfF+9KX7KBTUIs/jQO/7e7/u8cZxhVP2/aDnd5/CQzB8FqGwOI+z+jjZjigLKBTs0nTR9fUcJ34vdGwOSuxEft+5J4qUtq4IBFl0zketOwjK1WYrUmP/CB4cY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320203; c=relaxed/simple; bh=Wjn6ahfpV7yn/8rD5L4qV2HHdeT2hQ8Tt+KFgMreko0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dtGxnoCkR5bo0YdRCavb2WYndpJdn5Y06zpUxDm1EkJllSGTGLglh3Ssl6ctMKH38heO/AQXCGormUFToFUzFMMLhjaWoVyoctFFhu+af+R5UTL4zoX4E/+H6nhN3LTLxb2GFT9i+Q7iHQXn95xyB9WO9SpsejQBJWNLWr6KeCc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K9iS4LRa; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1ADB0C433F1; Sun, 24 Mar 2024 22:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320202; bh=Wjn6ahfpV7yn/8rD5L4qV2HHdeT2hQ8Tt+KFgMreko0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K9iS4LRabGNK0US0cmkL2cUoB5a81RpY68X6yzZHhbGdmrz/Dm4FQbdnDfXzOn5m+ M4b14USdIXTzBv7IVvSpy+NQEE+bZhxcQ5+vsaDvU2dEH73TY5CyC42xeDh1Yc03y7 dyRmn09QgEWInhdJXsjniynYuwJZagzskQEqYnS2c5rJ18BSTliIZTnWoFaxRe1pf7 RfFLH3EQP1LARAHjDK5AnoEbmg4KFvP5pZa8EgBlGuX6orfDB87zpz0gMLUo7Dg27i LNXYVUb5UfG25IxlExD5rxtak0fNHUB6EEUlWuleiHpGAfyl36T0YbZDfwNcHezR6/ LqNUVLhScjcvw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Matthew Brost , Mika Kuoppala , Lucas De Marchi , Sasha Levin Subject: [PATCH 6.8 510/715] drm/xe: Fix ref counting leak on page fault Date: Sun, 24 Mar 2024 18:31:29 -0400 Message-ID: <20240324223455.1342824-511-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Matthew Brost [ Upstream commit f7da398935f7ddabf1a098714593e032c875cd74 ] If a page fault occurs on VM not in fault a ref can be leaked. Fix this. Fixes: dd08ebf6c352 ("drm/xe: Introduce a new DRM driver for Intel GPUs") Signed-off-by: Matthew Brost Reviewed-by: Mika Kuoppala Link: https://patchwork.freedesktop.org/patch/msgid/20240301041036.238471-1-matthew.brost@intel.com (cherry picked from commit 27b5a3f237fe66dbf2288c2b50973aee8a427e41) Signed-off-by: Lucas De Marchi Signed-off-by: Sasha Levin --- drivers/gpu/drm/xe/xe_gt_pagefault.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_gt_pagefault.c b/drivers/gpu/drm/xe/xe_gt_pagefault.c index 73f08f1924df2..e2cf1759527c6 100644 --- a/drivers/gpu/drm/xe/xe_gt_pagefault.c +++ b/drivers/gpu/drm/xe/xe_gt_pagefault.c @@ -146,10 +146,12 @@ static int handle_pagefault(struct xe_gt *gt, struct pagefault *pf) /* ASID to VM */ mutex_lock(&xe->usm.lock); vm = xa_load(&xe->usm.asid_to_vm, pf->asid); - if (vm) + if (vm && xe_vm_in_fault_mode(vm)) xe_vm_get(vm); + else + vm = NULL; mutex_unlock(&xe->usm.lock); - if (!vm || !xe_vm_in_fault_mode(vm)) + if (!vm) return -EINVAL; retry_userptr: -- 2.43.0