Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp264701lqr; Wed, 5 Jun 2024 05:38:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVd69MBTNGFw9ThYvPklSWj9XoPBPtDOMLS3D6VYY3C1CQ1SjjCk7lrUDq+jtzMceVv+QE8tsTd7szEHEG0Birta1nceClOJpQJme70wA== X-Google-Smtp-Source: AGHT+IE915ZXQ1EgVBCvg0BPCsLWNVwI8baPMvIZZxEcPvnqVBf5o7MlDhNHBrMuA4t75bBLZ6CY X-Received: by 2002:ac8:57c4:0:b0:440:25d4:8053 with SMTP id d75a77b69052e-4402b466a18mr22857271cf.6.1717591129045; Wed, 05 Jun 2024 05:38:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717591129; cv=pass; d=google.com; s=arc-20160816; b=IyqWxfeCm6DI9C3uEg115BLwNTxkWY/wjjnBipTDE4UpiBEgyL/JpYn76lzRp13Xiv EgMsAzI8uzuvPNHiSpt74x4/XAxQbQY5ao6aup25OuNtLJU5jlLPiKP0wMOFQUBar5e7 HDNFjHHtVdNoiCABlPBVvi37Pi5T4ytitkelbyHwWxy7P1zfaWCJVFiTquncvmwC2sUI SDDK+vzy6zE3HTDtxczLj1ONrJHuo50zl4llKMaSi5byZgv7m8bJ8MKBad9SuErTwIg5 m2A5NwCOuUUEvPKTyhYgdSG1Yb6i+lz/y9yefVZjXFRHchXabEkIiW+eNTCotb2hSC5W a3yQ== 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=XyLJkDMtZHEGLGZWPmvOO/zPWmsqrlFSQlbZfJh/MGM=; fh=HwM7MjNiztBVt0fuh7keBCaOqG9L4yuL2vEwHVcIF4k=; b=eJLh4M9O4aFnfy/ovbx7omzjCtM7FsViML2luu2QqalIQ8eHlhKQoZXoAlObS+jG8h v0AnrHC+Iqk6v77y9bi+qgPf9a25bEbn0DiBdMH4y34l03TJSJccofw+YNuKzOWDbbr0 UWRNxeaRCVgBSsx9DvOofF1lrsn6Ncv52cJsD/eLoXWmnf9/d6JSrAY0vh1WmqLvssaB /JFbaLIGAvTimSFmthTQPw5ZJOliWnz2q2ZTklUUL+RriHSq65H7o6dqdM9+Mkkr21oZ z0HisfEWNkC/dmWTj03Vwcb81cbiIklJ0OLBSzy6u5EiNWMUD8ZRLe2s+Oz5r/CAGvfQ 13lA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XXj2k8lp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202491-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202491-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. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43ff25b2de9si34132411cf.713.2024.06.05.05.38.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 05:38:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202491-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XXj2k8lp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202491-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202491-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 C0CE11C21C4A for ; Wed, 5 Jun 2024 12:38:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 782D81C4B5F; Wed, 5 Jun 2024 12:03:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XXj2k8lp" 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 9FD171C5380; Wed, 5 Jun 2024 12:03:51 +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=1717589031; cv=none; b=F5YHv0G98wsJiSZZ/toGC8dcCfk0c62srr5N5jUEKGAEvRH9biqCgbVNwUk6V2qPf+eRg5Y3EgU0wmNICVIQ6BxZ4kkyyAasQ/RjDz0lC2eAmwPJ42439lp9VNlInfJVM5I1GQ19i7KVlE0HxUDegQfEL+G9FTMov7Q2EmhcYA4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717589031; c=relaxed/simple; bh=VB9SDG8gr31R2W8OWY7ctbZhG9qXo6auRWU3/Xy/4DY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=DSO7SKsBaXuFPErBHPpWAjhrQzrsOwC3oJiTBqIEgRfbkQlfpLEBky1jYNh8rAJjN/bmbRIqm89uOcM+NCq/bOqfRrIAMlKsdhJjYIXwHjbPBAtGvQYa+3Hd1dkE2A7tlqPEThxDCQXyEPwFzyofqBF9jdrA48C5sr9cRI7qFwE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XXj2k8lp; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC4EFC3277B; Wed, 5 Jun 2024 12:03:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717589031; bh=VB9SDG8gr31R2W8OWY7ctbZhG9qXo6auRWU3/Xy/4DY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XXj2k8lpi5jCEWgJt0t8CbVvvhVTzc9flHelIvT+rY4aU94V88t1M5hEV5nCgiD3a JxCnbmNf24hN3ifQgal9AswGo5GoBrHzDD/Z+kro/1Ra7YLOv7U4O5NHQGEfU9BgXs K+e8qNc3mRlEEoDUYWsuTUOQ4zpuvUnaxzxI7W7P/LGkrmNa/N9ay93nKFmPiQzVQm lZeK2mZmVZZ6KiW8/JEtZQcD3c/4erhW3nCbs+wOyv1sWUiAmzQ0Zez7OmsYK4kXRl B4lvz0MMvrKZVGtVz4V2pnyHxrp+62uOesN+bUb8Cu6lYtwq8TCBcnGV8nAvxDCmkN 2FWhVBy56n/gw== 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, guchun.chen@amd.com, Philip.Yang@amd.com, mukul.joshi@amd.com, xiaogang.chen@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 6.8 16/18] drm/amdgpu: fix dereference null return value for the function amdgpu_vm_pt_parent Date: Wed, 5 Jun 2024 08:03:06 -0400 Message-ID: <20240605120319.2966627-16-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605120319.2966627-1-sashal@kernel.org> References: <20240605120319.2966627-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.8.12 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 a160265ddc07c..099e375a39ec6 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