Skip to content

Commit d7a254f

Browse files
srishanmalexdeucher
authored andcommitted
drm/amdkfd: Fix 'node' NULL check in 'svm_range_get_range_boundaries()'
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 <Philip.Yang@amd.com> Cc: Felix Kuehling <Felix.Kuehling@amd.com> Cc: Christian König <christian.koenig@amd.com> Cc: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com> Reviewed-by: Felix Kuehling <felix.kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent c3d5e29 commit d7a254f

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

drivers/gpu/drm/amd/amdkfd/kfd_svm.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,6 +2654,7 @@ svm_range_get_range_boundaries(struct kfd_process *p, int64_t addr,
26542654
{
26552655
struct vm_area_struct *vma;
26562656
struct interval_tree_node *node;
2657+
struct rb_node *rb_node;
26572658
unsigned long start_limit, end_limit;
26582659

26592660
vma = vma_lookup(p->mm, addr << PAGE_SHIFT);
@@ -2673,16 +2674,15 @@ svm_range_get_range_boundaries(struct kfd_process *p, int64_t addr,
26732674
if (node) {
26742675
end_limit = min(end_limit, node->start);
26752676
/* Last range that ends before the fault address */
2676-
node = container_of(rb_prev(&node->rb),
2677-
struct interval_tree_node, rb);
2677+
rb_node = rb_prev(&node->rb);
26782678
} else {
26792679
/* Last range must end before addr because
26802680
* there was no range after addr
26812681
*/
2682-
node = container_of(rb_last(&p->svms.objects.rb_root),
2683-
struct interval_tree_node, rb);
2682+
rb_node = rb_last(&p->svms.objects.rb_root);
26842683
}
2685-
if (node) {
2684+
if (rb_node) {
2685+
node = container_of(rb_node, struct interval_tree_node, rb);
26862686
if (node->last >= addr) {
26872687
WARN(1, "Overlap with prev node and page fault addr\n");
26882688
return -EFAULT;

0 commit comments

Comments
 (0)