Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp269225lqr; Wed, 5 Jun 2024 05:47:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU89L37iH9IXmLlUNIFvzw+yCmuMfzvLPL9FndIoDQYJ0Slkai2I0cIKnNLGRHHNbbSswRG2o4Ei438/KQX8T4uvkV6VOqDDYf3ralwBA== X-Google-Smtp-Source: AGHT+IEhYp9sgXd67Is7fi4yz9MB/ro+1ex84YMBH5fZz+Zx44S82jK1YlgXons4XbF4Wx/d6Uwz X-Received: by 2002:a05:622a:510:b0:43a:b16d:a0ca with SMTP id d75a77b69052e-4402b69776dmr27232061cf.60.1717591660325; Wed, 05 Jun 2024 05:47:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717591660; cv=pass; d=google.com; s=arc-20160816; b=JPJ1+DLFNAHJaqqMFj/xo8ORNbpetNfm0K/CgqRqpOBIVUjmz4umAIo/7QbdV5RO2w 2oDfaXU+3/zKXH7B8St6VJSXSrNIrC2fvvaoNBifwC0z01jxCVm54Bx42BrXUCNvqhLw EA94yC33HoWWb8x6tkFk59dJnl9w/08h76E4FiohRVaJqAZE4k17gA8A1m2uvJIG2oqF Bad6L3H9SdR/Nfg6QAUUo1736rM46qSEbi4jzwlBjWsQkflSycg/YGKxQgcryIZ5aM/z D/epGFjmJ0RgRu9AtwTJ5+b02bzhDS0PbixFkTm7aYsdOVIsLLS5BDbZThddeYw4rHbD Jh8A== 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=ZczqQZeKvl7hp7dpBqTaSU6lC0RZ0EEfPQHKvOqS1pA=; fh=HwM7MjNiztBVt0fuh7keBCaOqG9L4yuL2vEwHVcIF4k=; b=EtQ1eJ8C79M+umpgbYea2t5yFmz21yeOKcd8DIPNReEVPqAmj4GTWYpaRw7MmaaRY5 D4lxwGl5qUc11lg6puZjAdl4b5xYh9GyyLVM/GhfUwBPGPPgiLKQuSLQ9c0+yuXziuxq fsH7CJBftHN05NU4zS1qL3eyV4MMQMojQtGcEj0u6kYvX0V+Txr3MuHkcvnfotWYHBeY EzJ01B0Lli8Br1F85I5ZXL4pe3ommFC5U136JV6Y3lcQw8zQOIK//jOpf4cxPIDQi4ss xGiu3ZS6Xp98/UERaIo2DgK9MxM0l1d7R4HJ7dgoNiYxDvNJZD750deGe1KD9WUXsia4 T2QQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=m4KDWDzv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202526-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202526-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 d75a77b69052e-43ff23aea1fsi27751711cf.100.2024.06.05.05.47.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 05:47:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202526-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=m4KDWDzv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202526-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202526-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 1277D1C23F4B for ; Wed, 5 Jun 2024 12:47:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA455195990; Wed, 5 Jun 2024 12:05:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="m4KDWDzv" 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 DEA561CD448; Wed, 5 Jun 2024 12:05:18 +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=1717589119; cv=none; b=Lnjdd/4MXsOG9dDQt+o57g14xfgbtx4/QLIKFyHWSzUbINEu9J7Kq02j5vHgrpeUyZAajVBcGE4WcIjvqzAnsQyrCZXCZoX1XkSzb0p5SznVDXguNhqMlTy4h0JuIZgbXteitnVdjJrkt/9aYruVRw8sfsVcZo0saTgeyNoIvww= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717589119; c=relaxed/simple; bh=qQuitPoq93Dql+IO0stmpexe7lWd2SiPR91hJ0WDJ/k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ueFWdYXS0CQmzt59c1NVWt/QgXQb9A22aTwV+c8M9X9L+c5GuGhm4yPIEfHYMY/LuXWb3VPiW/HwT8TRM2rXgejKf0NqvCoZKsVlUHI0VLncGaFYEnFQ4K186ak6ym2YECpdMAE3mJuNU8aBGb4OLHM+Ipct+3SYBBN0rnrj904= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=m4KDWDzv; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F12EBC32781; Wed, 5 Jun 2024 12:05:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717589118; bh=qQuitPoq93Dql+IO0stmpexe7lWd2SiPR91hJ0WDJ/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m4KDWDzv78u4Qc5Lss1IhyGHk6z/lbEuJiS5k9O0oaDV5eLVC2+5cAjRqpHVP9tRi y1YJLHqK39A551DJsgLkna3D5INDkS9azzdAD99dohCvL4hM9By6a/C6/x7uJ/grbb EMbtz5wYWqrn+X694968tOaBgKGhr1lu6OpNujZBJV/EuGFI60bQqwXOeSHZouEf3a 9aQtg497ASk6aJHZo6PAcp4hwnV5qvk1zp43gdNTRDn74JCKL0GRMDfg8U47gBn7aT ctmvDFBoWsKA84KR5XmoyuehfWCnscgz6t2O1r1l9mFXrP12+H03gv+wYaaxV7Yh8y CCx4JWy6LLdYw== 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.1 13/14] drm/amdgpu: fix dereference null return value for the function amdgpu_vm_pt_parent Date: Wed, 5 Jun 2024 08:04:46 -0400 Message-ID: <20240605120455.2967445-13-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240605120455.2967445-1-sashal@kernel.org> References: <20240605120455.2967445-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.1.92 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 69b3829bbe53f..370d02bdde862 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm_pt.c @@ -754,11 +754,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