Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp267221lqr; Wed, 5 Jun 2024 05:43:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXqq+08zfTcW8K1w8pBsLGyfoqia+MDG4xfMxAQswZHfWpUBJXPK3vg+xBdZ3fjwnBjTyuNlzVM7J6+RLiWOt/kMBQv/KYT9nX3zkPSVw== X-Google-Smtp-Source: AGHT+IFLamOAqC/4A0t09lj0FjknvT+NSxeQj7OXIvYZaOUwK+DrM0PtttZU3+yH7/D1rjYHZ2py X-Received: by 2002:a05:620a:46a9:b0:792:9f1a:869b with SMTP id af79cd13be357-79523d56060mr292786585a.42.1717591430819; Wed, 05 Jun 2024 05:43:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717591430; cv=pass; d=google.com; s=arc-20160816; b=jnejtFBM8L6MZIoTTAxgehjYCzrvNnhr6ALZCLk/x2QFfHJKCymeQSpv4yU6rtkuzs ysCvMKsAiLpmRTsd3SngTQEK5olB3QPdpUZamyAZm0C7SCFthTP9IPtb3DtGIJR/WMXP YS76A7DuRT7qPWmgsMiXp0rbE/9AO2ufs2IJyfLL8er3+OlMmWfNNtBYt2gVBkJmQIsM YtaUCNmFaXuQwTuX2UIhTz4h0yqswL3jD1qvRHlovHesBkWfc4DacnBrUT7COiPTsKdP MQ7xfDqMDM4FmTy1NO5Ohm3ihUItqTB2wmqQn6ZvqfnWbQxFUry8nwN8emQhFsc7bUyp uLJA== 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=T99upMpYXJV4nUV7mihkhEna1S+kaYw8aMKv8UYurKg=; fh=XkBWqiOD4MJee1F8P/NoB8Ofli2gueNPdR/08n9wD0E=; b=f0Ki99lUJcndy1IzsJ9fqEOm+J7FKafsN/w7Ys3elzU9qH09hZdxCXUVaJLm6FIf79 ar2xGgaVn1ozou5w5ft1yYROHxt+0cqEoaN2P/AbhVbKW046wQeNaeIsE6EDuU+Nn+61 M2eCGJ2zapCYHrcX2yueipy7Zxn+q+OmQmyIFrVopwm0xWohGrmNgWqUzaJPVExpevfx nOauk/DbR//SxLcLbncW8ubRbC/oHAn9jKlmJGEeK/+BC4cGB7b2c7PDkPHQYQiZ8seO DHsdo3OdLb4AhYaRoIbZ9P8/+QiyLnhFz35xqBF/l9RkTw4iqUU5vI573A0C5GzcaHed LwTA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Iv6DeN51; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202511-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202511-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-7951de77eedsi64308485a.135.2024.06.05.05.43.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 05:43:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202511-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Iv6DeN51; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202511-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202511-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 568271C23B96 for ; Wed, 5 Jun 2024 12:43:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C72E41CA2EE; Wed, 5 Jun 2024 12:04:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Iv6DeN51" 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 F01E61CA2E4; Wed, 5 Jun 2024 12:04:40 +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=1717589081; cv=none; b=XxEK91FGx9Eb+UcPBRz+1BxSasXxEQ9OYx0SL8yCpdvIFev+iLWyuh+6YJYfwC9SlfzeuShHhfJ9Mo2MwJcYBBsjgrYAb+lZLHhAhPjzsWOxkn0AItKTgwUwx/uVIrB2Ca3N+q98wuBlO+VcNxm5PcimfNSuWP3jNAH/dxXOxwA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717589081; c=relaxed/simple; bh=Vjgiu0ILR3uskzK21Z0875GunoRwQmq+BkAqVYl9M+k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=F5mK5EcBZslZHCtggNTQblXZkwH2UTWbQLab35CjJNj3h+9uZN0H89uYiQHzmtkQlnJzMiWuMLTzIocKGp+P34VBWE4eWbc1pAbZKFfA9/jZ7JcSCaco0WAi54n7o7b+SSxWejiU67mgJq3DZAHT6Yup4c2kIQYFT6pR3BRhWt0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Iv6DeN51; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03F53C4AF09; Wed, 5 Jun 2024 12:04:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717589080; bh=Vjgiu0ILR3uskzK21Z0875GunoRwQmq+BkAqVYl9M+k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Iv6DeN51QEggnAkiZVE+/TVBGNJ8z/dhDsrdGN1VrJUGkQWgrzeJ6aQ0472Tgnf+V 1/myHM4lIEneJ9IjoYaxVnOlC/lywW/ZgBUbXVBkhphiXOxe5euLNsQNQwQ7mei/Qe AkV0nveOyckT0/QZbl0EuQJEOnq6m6fVfrl7f9Jz0P6s/QfasWgyy39Rh7IAqHfhbo 1oWrMCBxkqfBISsMBzuZP4akNgflmwbPh3eoj36SuXnSlvFU9KikMqypKkiMcIj7oX dDB9wS7LoUI8X3ExTDBTclCwRrBCHQ9BVKrbOfx1wwCjMers/o1p1Ca8UMnhPoLD4n ctUrt1xOm+XrQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jesse Zhang , Jesse Zhang , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , Sasha Levin , Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, Felix.Kuehling@amd.com, shashank.sharma@amd.com, Philip.Yang@amd.com, guchun.chen@amd.com, mukul.joshi@amd.com, xiaogang.chen@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 6.6 16/18] drm/amdgpu: fix dereference null return value for the function amdgpu_vm_pt_parent Date: Wed, 5 Jun 2024 08:03:55 -0400 Message-ID: <20240605120409.2967044-16-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605120409.2967044-1-sashal@kernel.org> References: <20240605120409.2967044-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.32 Content-Transfer-Encoding: 8bit From: Jesse Zhang [ Upstream commit a0cf36546cc24ae1c95d72253c7795d4d2fc77aa ] The pointer parent may be NULLed by the function amdgpu_vm_pt_parent. To make the code more robust, check the pointer parent. Signed-off-by: Jesse Zhang Suggested-by: Christian König Reviewed-by: Christian König Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c index 0d51222f6f8eb..026a3db947298 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c @@ -766,11 +766,15 @@ int amdgpu_vm_pde_update(struct amdgpu_vm_update_params *params, struct amdgpu_vm_bo_base *entry) { struct amdgpu_vm_bo_base *parent = amdgpu_vm_pt_parent(entry); - struct amdgpu_bo *bo = parent->bo, *pbo; + struct amdgpu_bo *bo, *pbo; struct amdgpu_vm *vm = params->vm; uint64_t pde, pt, flags; unsigned int level; + if (WARN_ON(!parent)) + return -EINVAL; + + bo = parent->bo; for (level = 0, pbo = bo->parent; pbo; ++level) pbo = pbo->parent; -- 2.43.0