Skip to contentSkip to conversation

drm/amdgpu: add error handling for drm_fb_helper_initial_config

PATCH New Danila Chernetsov 1 participant 1 message Mar 12, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: add error handling for drm_fb_helper_initial_config

The type of return value of drm_fb_helper_initial_config is int, which may return wrong result, so we add error handling for it to reclaim memory resource, and return when an error occurs.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes d38ceaf99ed0 (drm/amdgpu: add core driver (v4))
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c +11 -2
index 43f29ee0e3b0..e445a2c9f569 100644
@@ -348,8 +348,17 @@ int amdgpu_fbdev_init(struct amdgpu_device *adev)
 	if (!amdgpu_device_has_dc_support(adev))
 		drm_helper_disable_unused_functions(adev_to_drm(adev));
 
-	drm_fb_helper_initial_config(&rfbdev->helper, bpp_sel);
-	return 0;
+	ret = drm_fb_helper_initial_config(&rfbdev->helper, bpp_sel);
+	if (ret)
+		goto fini;
+
+	return 0;
+
+fini:
+	drm_fb_helper_fini(&rfbdev->helper);
+
+	kfree(rfbdev);
+	return ret;
 }
 
 void amdgpu_fbdev_fini(struct amdgpu_device *adev)
Signature · 1 line
2.25.1