Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp780912rdb; Sun, 28 Jan 2024 08:38:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGvKVMWD5gPSGt06gjX+lp6uIzRTx8B0ZwL1SQhbP2s6iQVBz1FkKG5OwccUJnU3cy3WfdU X-Received: by 2002:ad4:5fc9:0:b0:686:ac63:ef34 with SMTP id jq9-20020ad45fc9000000b00686ac63ef34mr4117389qvb.8.1706459910261; Sun, 28 Jan 2024 08:38:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706459910; cv=pass; d=google.com; s=arc-20160816; b=HadZf8c1bJ1s9iEj9JlwkvCLBTc73m9iI2UxxWGEkhbA9uRy9QmVQqX3RSOozVSaNj WC/b8x8NK+4KgQTRlrnS2OX9lsz+F4yxd/YJatlFpJ0fYk5xFJ1rmKbcpgliu11dv+yX KtCvdTGDodTcwu47FvUoLoeA0PMNJa3z+tGUXjMlZCLQk1UPV/cssuVhltZNgfNPuoLo CJL3i1NbZxCH98SYlY1rddmK47vHNyIkY8wxSPP+76gdepN1+YCqYODMpeamfw+lyR4V ba5LbeUQf+T+eCHQPlDTnWxJyxUa4pknG7alXFcnOKHhvSTNgXjLT/3AAAqusLUvrOYn 47tA== 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=AwCkWoYr51Q8txPFfJL1g9F3e44GcTaGpA45dCKjDeQ=; fh=JA3a5iwsU8LyJwSlc6/thl5q2P8hkneHE6ZjAmiXlao=; b=fvxRSimfnnht/GUOeVLXaStl0QdhSyxvuqsgF9TRK3K317+xtLIu783QrHx5upcGeK lAPptbFlmEDldZ8SXQtZ1u2Nu8Hh/xizdsAaTh5FAzNWcKGDhZcqNGm8g3BnihGMBkxe 19ObwwA50BQU6YLBbLqEzL45ALTK6wOsHYj37TSRb7vaDtRqp5lHEXYRqqKmVXE1rvme 6emklNwe4ozU8NFvSZYZh+h1uCeuECwYOiFFuUqlkSNs1rhdn7HAM/2Sg4EXy+upTGuP G4dE5iDdHknlh+ooa3p75sA/k/g6gGtO6mkXb3WNUfTRFqh3U4nid3mTiaflI+A4zWca Ll6w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=azOleIcH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-41781-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41781-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 im11-20020a056214246b00b0067f69d71261si5884374qvb.13.2024.01.28.08.38.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 08:38:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41781-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=azOleIcH; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-41781-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41781-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 0ACDC1C22431 for ; Sun, 28 Jan 2024 16:38:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3A582129A8C; Sun, 28 Jan 2024 16:15:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="azOleIcH" 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 5F0294CB5C; Sun, 28 Jan 2024 16:15:14 +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=1706458514; cv=none; b=G2xLXNfE6E6UqJLd7cwf2tYYTiFyHQIZdNY35qZCYZdjaUc3XmSMqEu1oz/kI5PJRja+KbJsryzXyizAugPjG/mBUoDXpk67uxUe1ztY1LMKPNI17VoOmtxRHioB+Th6ZlPo657W9rr3uum/XJ2IfFOc5kiafVSehpJZVPWI5o0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706458514; c=relaxed/simple; bh=NpCssRGcPw6Ho6Q1LNkhGIO2w4cpnGoDPuYXWBLOIns=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PM5BRzYWKQZ7TP3vdVULHkf7Bu9ezjEg8RUZ8mANirvIBEzxasCIlNDxe14ai9nIDSmKbTZrnHZ+Pd7GcUrFKt4hHagDz2TlkfIAUJzxPJ6jfr4PfBUWkyLgOVJT1D94LQ71UpepuxT0wbMWMXnijxyRBg+82CT0/NFnfeaXZa8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=azOleIcH; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF7F5C433C7; Sun, 28 Jan 2024 16:15:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706458514; bh=NpCssRGcPw6Ho6Q1LNkhGIO2w4cpnGoDPuYXWBLOIns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=azOleIcHycB9c7GtudfTyKsscHRfNYAoli3++BuxP+QXi3mhKmACH1YiUE2BE2zXR ic9bUNaUV7YGH9PVCpsrc40Rh+7F8PWuLrfwqiC4lXPbvwNSykZgZnVeM8tQuEg/yL 1xaNFh2QzWHrPnK+PDUrKFsT48L+7+HQwioHLnL7YloScd40abazok1ekRfbO4w7Dn oSnE3Da88w5jzr4wLgT2wXlpuR1uYPBQ0sMRNhj3hRpjJNMBfgE48gIyuirt0SPF3q B3eMCambfS12iluXTQITaBBpTe3/PN10Z9PkLuJG/KoHvu+tTxetclB/hG6nIxIs0J rJC+6HBhRvbug== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Srinivasan Shanmugam , Philip Yang , Felix Kuehling , =?UTF-8?q?Christian=20K=C3=B6nig?= , Alex Deucher , Felix Kuehling , Sasha Levin , Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 6.1 26/27] drm/amdkfd: Fix 'node' NULL check in 'svm_range_get_range_boundaries()' Date: Sun, 28 Jan 2024 11:14:11 -0500 Message-ID: <20240128161424.203600-26-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240128161424.203600-1-sashal@kernel.org> References: <20240128161424.203600-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.75 Content-Transfer-Encoding: 8bit From: Srinivasan Shanmugam [ Upstream commit d7a254fad873775ce6c32b77796c81e81e6b7f2e ] Range interval [start, last] is ordered by rb_tree, rb_prev, rb_next return value still needs NULL check, thus modified from "node" to "rb_node". Fixes the below: drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_svm.c:2691 svm_range_get_range_boundaries() warn: can 'node' even be NULL? Suggested-by: Philip Yang Cc: Felix Kuehling Cc: Christian König Cc: Alex Deucher Signed-off-by: Srinivasan Shanmugam Reviewed-by: Felix Kuehling Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c index 5188c4d2e7c0..7fa5e70f1aac 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c @@ -2553,6 +2553,7 @@ svm_range_get_range_boundaries(struct kfd_process *p, int64_t addr, { struct vm_area_struct *vma; struct interval_tree_node *node; + struct rb_node *rb_node; unsigned long start_limit, end_limit; vma = find_vma(p->mm, addr << PAGE_SHIFT); @@ -2575,16 +2576,15 @@ svm_range_get_range_boundaries(struct kfd_process *p, int64_t addr, if (node) { end_limit = min(end_limit, node->start); /* Last range that ends before the fault address */ - node = container_of(rb_prev(&node->rb), - struct interval_tree_node, rb); + rb_node = rb_prev(&node->rb); } else { /* Last range must end before addr because * there was no range after addr */ - node = container_of(rb_last(&p->svms.objects.rb_root), - struct interval_tree_node, rb); + rb_node = rb_last(&p->svms.objects.rb_root); } - if (node) { + if (rb_node) { + node = container_of(rb_node, struct interval_tree_node, rb); if (node->last >= addr) { WARN(1, "Overlap with prev node and page fault addr\n"); return -EFAULT; -- 2.43.0