Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2489814pxj; Mon, 10 May 2021 04:21:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwa2+soNmjWlVUwSWQSenmwQaXzBaSMivdM+uUeKJu9PINuww1VZisOIhUGj/g43umxE4rt X-Received: by 2002:a92:2c02:: with SMTP id t2mr20923740ile.233.1620645667297; Mon, 10 May 2021 04:21:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620645667; cv=none; d=google.com; s=arc-20160816; b=PGIogpCgnrpw6u5Ci9Fn8cxMhTrWSABaxvH53xsspq2v7RP7q2jSLCx+VG9nW693z2 6gjHZbt5HMc3evb7LHRleA77AIjgL8psuNY3cDgVY9LGLG7WJ6L0bdkDh22kMiWsGxRo yzCXY+nKKGYTAe01FDykaIIhvKg+ry2nfFMrpAHT2JvxNu/qgKS65kD4pjhNSyOPSzwT Fz67MA44HAWXJysK0qEcUSPDX+Nu68k1mFfIt85rd9BAVhsBEaI4F/Q4b/4sD5ckZ6e6 ldzts1tEIVILroEPBdRSlMKnkc38ewfCBNM+EotUtyxNrjwgWhDfvaugbz3Xt1eSFDfT evsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2B2+KjqJ+xELNCJ0WqWJc2dYy7KzBPlT8aSVTFUHyh8=; b=bEOZqbIRCSM9wiMXO7pD/bwavF2tl/29zCmPi1CPzhsjDmXKgzlSN0+P/cbyn8glGs LrDDKgh0xGjMfc3mxURqpXYzOKX6sTYx/QQQrfv7pQhsbi1CiQIUCMVVHAYgz6kjhCoE /SS5k3RD0Vy6dJPK6ZGB4ywP4CYJwKD0kvypRItWYo/v+UDGsf/SPaxLFHEa5Nzau9kR EFpQtrh5x4jmB7T0XGiJ0QiorpoZ6cjC5iJ+Nb1QvHELed/gSFmo586oMLsNYMW7D16/ Dr9DrQJg/8ckbeEE7HxFEOHNAFtmOCsjVyDJReoTpS0HD0p7kXtDHpDJga5ZHYxBR3N3 URtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="f/AxEpDC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i17si5813993ila.99.2021.05.10.04.20.54; Mon, 10 May 2021 04:21:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="f/AxEpDC"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238030AbhEJLQu (ORCPT + 99 others); Mon, 10 May 2021 07:16:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:46508 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233210AbhEJKwM (ORCPT ); Mon, 10 May 2021 06:52:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2E20861613; Mon, 10 May 2021 10:40:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643251; bh=Jtz0F+WJvYDVDzLcsIfgGOia+DL+n4RdqjTmRQueIJY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f/AxEpDCpY9etK7YOg47VkRHAQOX8Ohv3s73Zb2Qnv1SiPaK7rcZjGnlXVV84ulME Pbzq2Sbhny/XbxizxKKPsRMD0rseSvmACfH93Rj9xc7bXmtZGItVHnkTQo8LcgUe1L wOO1kL0PfF8Rjx8wFwfzxL6Eqyq6aAwKwpjhRCoE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guchun Chen , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , Sasha Levin Subject: [PATCH 5.10 195/299] drm/amdgpu: fix NULL pointer dereference Date: Mon, 10 May 2021 12:19:52 +0200 Message-Id: <20210510102011.386072255@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guchun Chen [ Upstream commit 3c3dc654333f6389803cdcaf03912e94173ae510 ] ttm->sg needs to be checked before accessing its child member. Call Trace: amdgpu_ttm_backend_destroy+0x12/0x70 [amdgpu] ttm_bo_cleanup_memtype_use+0x3a/0x60 [ttm] ttm_bo_release+0x17d/0x300 [ttm] amdgpu_bo_unref+0x1a/0x30 [amdgpu] amdgpu_amdkfd_gpuvm_alloc_memory_of_gpu+0x78b/0x8b0 [amdgpu] kfd_ioctl_alloc_memory_of_gpu+0x118/0x220 [amdgpu] kfd_ioctl+0x222/0x400 [amdgpu] ? kfd_dev_is_large_bar+0x90/0x90 [amdgpu] __x64_sys_ioctl+0x8e/0xd0 ? __context_tracking_exit+0x52/0x90 do_syscall_64+0x33/0x80 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x7f97f264d317 Code: b3 66 90 48 8b 05 71 4b 2d 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 41 4b 2d 00 f7 d8 64 89 01 48 RSP: 002b:00007ffdb402c338 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 RAX: ffffffffffffffda RBX: 00007f97f3cc63a0 RCX: 00007f97f264d317 RDX: 00007ffdb402c380 RSI: 00000000c0284b16 RDI: 0000000000000003 RBP: 00007ffdb402c380 R08: 00007ffdb402c428 R09: 00000000c4000004 R10: 00000000c4000004 R11: 0000000000000246 R12: 00000000c0284b16 R13: 0000000000000003 R14: 00007f97f3cc63a0 R15: 00007f8836200000 Signed-off-by: Guchun Chen Acked-by: Christian König Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 06a662ea33dd..ab7755a3885a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1034,7 +1034,7 @@ static void amdgpu_ttm_tt_unpin_userptr(struct ttm_bo_device *bdev, DMA_BIDIRECTIONAL : DMA_TO_DEVICE; /* double check that we don't free the table twice */ - if (!ttm->sg->sgl) + if (!ttm->sg || !ttm->sg->sgl) return; /* unmap the pages mapped to the device */ -- 2.30.2