Skip to content

Commit 9a5705f

Browse files
Chengjun YaoPerry Yuan
authored andcommitted
drm/amdkcl: fix NULL pointer dereference during module unload
The free_xcp_dev() function incorrectly uses the global pdev_num variable to index into the xcp_dev array. Since pdev_num is decremented during the loop, it can lead to accessing an incorrect index during concurrent unloads or error conditions, resulting in a NULL pointer dereference. Signed-off-by: Chengjun Yao <Chengjun.Yao@amd.com> Reviewed-by: Bob Zhou <Bob.Zhou@amd.com>
1 parent 656a5cf commit 9a5705f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/gpu/drm/amd/amdxcp/amdgpu_xcp_drv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ static void free_xcp_dev(int8_t index)
112112
devres_release_group(&pdev->dev, NULL);
113113
platform_device_unregister(pdev);
114114
#ifndef HAVE_DRM_DRM_MANAGED_H
115-
drm_dev_fini(&(xcp_dev[pdev_num]->drm));
116-
kfree(xcp_dev[pdev_num]);
115+
drm_dev_fini(&(xcp_dev[index]->drm));
116+
kfree(xcp_dev[index]);
117117
#endif
118118
xcp_dev[index] = NULL;
119119
pdev_num--;

0 commit comments

Comments
 (0)