Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp266897lqr; Wed, 5 Jun 2024 05:43:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXHeVMehwb2vRtYexZ5sTpIo7HXot46s9GEXCsmulGtK+z8cPNIWotna7R6XWfH4Zp3MI+OulMRcaMp4i1a/yuM+7LAT5WlAoydVVch+g== X-Google-Smtp-Source: AGHT+IHawRhv56R5VYTP/Vc/Q31S8rmb1kBJc079kVjJ7//YkmAJxOdFemg8WcW071N8q26Qxkb/ X-Received: by 2002:a05:6a20:918e:b0:1b0:111f:2b6d with SMTP id adf61e73a8af0-1b2b70ff185mr4241192637.28.1717591385671; Wed, 05 Jun 2024 05:43:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717591385; cv=pass; d=google.com; s=arc-20160816; b=moIV7ombagtlqLMazq45loNc5xt5xfD/BqlRl4yhAid65aIIIpfpIrnO6y+anGgkr3 cGMteSyRcK1hBZliwGuCC1KvfhFqiroNyycduuFoS4bxMfVTheF2J0yETfqvvJe2ZnCI co6PmIxWjpzxJLa/hznaLsuiBFd4GBuPCpfwJrJIdMR7drL34DJCbMnqUG0noD1dKFwV lZ9SuJBX3UgqFhZeQQXmzGJNy3r4jNry+5tJonriJvwdtbLjUSaOeoy20xX4kKOVQR/4 3idWDt8TZeKgjnQ3j76WYQQrF6PqOoY1gOPRXkgnUrnoNyEPn9LgMxDDTnEXil9pDMyC cIlQ== 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=5H7XJAPMeYXjXN2cxA5La1tc8KUf4ORxzBQPTqgjuzY=; fh=XkBWqiOD4MJee1F8P/NoB8Ofli2gueNPdR/08n9wD0E=; b=fx9VS+3hJshDYSghBZ5j3Wft7g/QnM6sa/DlKwudbLnxpooWtmDPEhqgsBXuK/YwnD q1eLNhEBIHw4gVJlJ6AhaCquM7YkazhDHAdi2bHQiEUxlDxYQmxA4A5V14X0xM0xOwpF 23PyW2ZFbkK4YG286bFkycSITkjX/PmbYVpufUgcFCQ76LugdjIwaD5HLV2TRxwVqsbi V9gWTv8kqM9osr82AAjhD+eLjIhyFl5LYcAMbx2vUeGEoAWd8BvcnlpSBQhtVEcpoDYJ +lgJ9NF/eKjfBe21aRpIVhtG3V1qxJoUHIOwg++j8rdnq0ISDW15GEXxxsN3PEwpeaXj a3zw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MkGDEzT0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202471-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202471-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d2e1a72fcca58-70242c293e0si3969429b3a.288.2024.06.05.05.43.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 05:43:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202471-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MkGDEzT0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202471-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202471-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E8CCD28B470 for ; Wed, 5 Jun 2024 12:33:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DD14C1C1579; Wed, 5 Jun 2024 12:03:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MkGDEzT0" 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 0FBB71C156D; Wed, 5 Jun 2024 12:03:01 +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=1717588981; cv=none; b=ikcJ+3PIc65YmwIW1vBuXYmQCtGLuegifezRRTBtJKpBrCc6Df42uZXdpey0VBWmE7/VYOVZ0GQR/ItKp/+42RHFI9yXeFfwF7SeqLFDQOfV0s8mb7LiCqaR75ScXSwwbKD2XY2qP7px54kRv51oIPM+viEK8hdowQ5IbGjC9uc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717588981; c=relaxed/simple; bh=uVevTPR/osKWsOEkjvF98Wwcb8jPDMSg6NxJx8m/h4I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p5/CN1POPWQjvhlKKty+06DYmLzeP5EJCMYxAEwYC1Lf9bPbULPF8VGhZH9FW7z4W/8HDTdPhZbQuVCddu/l/ssB/bGSKdnv8St6YxcdfoQHliTW4EfXzJ8+MExJ6uWBBpE0Zr3+Yzqfmv8hKSUSghxTl3VPRBif0nNDQ8OU0Fo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MkGDEzT0; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 15166C32786; Wed, 5 Jun 2024 12:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717588980; bh=uVevTPR/osKWsOEkjvF98Wwcb8jPDMSg6NxJx8m/h4I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MkGDEzT0Uq/9hnhNq09/lTP+spFUndLatikNyVRZqN/CvGZGgVI/SRyk7q4ERaTBo wjJaPws6RiWCh9SsAKUq1jFgWssvH2/t6GJmukRQidHnS5rOWHRp4t9hBHpuACEtRM QY6mBd3olYesiJS8/mCihz/7ocr3Mxk3J2dSdM5FI9C/Xf7knCVCb8M1VSbN29PiDr rcXPSZK1kXXjqb3xvPJ0aG9vj/cIjoGvAQfxDJdRYWpqYo7s6oGD+TW8GLYwAXni2q fK8TdvdepyoYXKFGC+1hVKq3zPNjEMISIJFNwa/WytoLsZKFVVvVR2r4CWf5DRWkK1 Qh7XOlAHM5qiA== 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.9 20/23] drm/amdgpu: fix dereference null return value for the function amdgpu_vm_pt_parent Date: Wed, 5 Jun 2024 08:02:03 -0400 Message-ID: <20240605120220.2966127-20-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605120220.2966127-1-sashal@kernel.org> References: <20240605120220.2966127-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.9.3 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 124389a6bf481..512b42225003f 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c @@ -682,11 +682,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