[PATCH] ttm: Add error handling for ttm_pool_mgr_init()

Óscar Megía López posted 1 patch 2 months ago
drivers/gpu/drm/ttm/ttm_device.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
[PATCH] ttm: Add error handling for ttm_pool_mgr_init()
Posted by Óscar Megía López 2 months ago
The ttm_pool_mgr_init() function can fail, but its return value was
previously ignored in ttm_global_init(). This could leave the pool
manager in an invalid state while the system continues initialization.

Fix this by checking the return code and jumping to the error path
on failure.

Assisted-by: OpenCode:1.17.8-Big Pickle
Signed-off-by: Óscar Megía López <megia.oscar@gmail.com>
---
 drivers/gpu/drm/ttm/ttm_device.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c
index d3bfb9a696a7..c880a0430363 100644
--- a/drivers/gpu/drm/ttm/ttm_device.c
+++ b/drivers/gpu/drm/ttm/ttm_device.c
@@ -96,7 +96,10 @@ static int ttm_global_init(void)
 		>> PAGE_SHIFT;
 	num_dma32 = min(num_dma32, 2UL << (30 - PAGE_SHIFT));
 
-	ttm_pool_mgr_init(num_pages);
+	ret = ttm_pool_mgr_init(num_pages);
+	if (ret)
+		goto out;
+
 	ttm_tt_mgr_init(num_pages, num_dma32);
 
 	glob->dummy_read_page = alloc_page(__GFP_ZERO | GFP_DMA32 |
-- 
2.55.0

Re: [PATCH] ttm: Add error handling for ttm_pool_mgr_init()
Posted by Markus Elfring 2 months ago
…
> Fix this by checking the return code and jumping to the error path
> on failure.

How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?

See also:
* https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.2-rc5#n145
* https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/stable-kernel-rules.rst?h=v7.2-rc5#n34


Regards,
Markus