<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">On 1/4/2025 8:45 PM, Jiang Liu wrote:<br>
</div>
<blockquote type="cite" cite="mid:70f5963233c8a34354ec8a9efebc3a7b4c7940d4.1736044362.git.gerry@linux.alibaba.com">
<pre wrap="" class="moz-quote-pre">Fix possible resource leakage on error recovery path in function
kgd2kfd_device_init().
Signed-off-by: Jiang Liu <a class="moz-txt-link-rfc2396E" href="mailto:gerry@linux.alibaba.com"><gerry@linux.alibaba.com></a>
---
drivers/gpu/drm/amd/amdkfd/kfd_device.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
index a29374c86405..fa5054940486 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
@@ -898,15 +898,15 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
if (kfd->adev->xcp_mgr)
kfd_setup_interrupt_bitmap(node, i);
+ spin_lock_init(&node->watch_points_lock);
+
+ kfd->nodes[i] = node;
+
/* Initialize the KFD node */
if (kfd_init_node(node)) {
dev_err(kfd_device, "Error initializing KFD node\n");
goto node_init_error;
}
-
- spin_lock_init(&node->watch_points_lock);
-
- kfd->nodes[i] = node;
}
svm_range_set_max_pages(kfd->adev);
@@ -921,6 +921,7 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
goto out;
node_init_error:
+ i++;
node_alloc_error:
kfd_cleanup_nodes(kfd, i);
kfd_doorbell_fini(kfd);</pre>
</blockquote>
<p>I think this change is not right: if <span style="white-space: pre-wrap">kfd_init_node</span> fail it does
clean up for the kfd_node that it is initializing internally. <span style="white-space: pre-wrap">kfd_cleanup_nodes</span> does not
need to clean up the kfd node i which failed to init, just clean
up the kfd_nodes that were initialized previously.</p>
<p>Regard</p>
<p>Xiaogang<br>
</p>
<blockquote type="cite" cite="mid:70f5963233c8a34354ec8a9efebc3a7b4c7940d4.1736044362.git.gerry@linux.alibaba.com">
<pre wrap="" class="moz-quote-pre">
</pre>
</blockquote>
</body>
</html>