drm/amd/display: prevent memory leak
authorgehao <gehao@kylinos.cn>
Wed, 26 Oct 2022 09:54:05 +0000 (17:54 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 31 Dec 2022 12:14:41 +0000 (13:14 +0100)
[ Upstream commit d232afb1f3417ae8194ccf19ad3a8360e70e104e ]

In dce6(0,1,4)_create_resource_pool and dce80_create_resource_pool
the allocated memory should be released if construct pool fails.

Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: gehao <gehao@kylinos.cn>
Signed-off-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/display/dc/dce60/dce60_resource.c
drivers/gpu/drm/amd/display/dc/dce80/dce80_resource.c

index dcfa0a3..bf72d3f 100644 (file)
@@ -1127,6 +1127,7 @@ struct resource_pool *dce60_create_resource_pool(
        if (dce60_construct(num_virtual_links, dc, pool))
                return &pool->base;
 
+       kfree(pool);
        BREAK_TO_DEBUGGER();
        return NULL;
 }
@@ -1324,6 +1325,7 @@ struct resource_pool *dce61_create_resource_pool(
        if (dce61_construct(num_virtual_links, dc, pool))
                return &pool->base;
 
+       kfree(pool);
        BREAK_TO_DEBUGGER();
        return NULL;
 }
@@ -1517,6 +1519,7 @@ struct resource_pool *dce64_create_resource_pool(
        if (dce64_construct(num_virtual_links, dc, pool))
                return &pool->base;
 
+       kfree(pool);
        BREAK_TO_DEBUGGER();
        return NULL;
 }
index 725d92e..52d1f97 100644 (file)
@@ -1138,6 +1138,7 @@ struct resource_pool *dce80_create_resource_pool(
        if (dce80_construct(num_virtual_links, dc, pool))
                return &pool->base;
 
+       kfree(pool);
        BREAK_TO_DEBUGGER();
        return NULL;
 }
@@ -1337,6 +1338,7 @@ struct resource_pool *dce81_create_resource_pool(
        if (dce81_construct(num_virtual_links, dc, pool))
                return &pool->base;
 
+       kfree(pool);
        BREAK_TO_DEBUGGER();
        return NULL;
 }