Skip to content

Commit

Permalink
drm/amd/display: Release clck_src memory if clk_src_construct fails
Browse files Browse the repository at this point in the history
[ Upstream commit 674704a ]

[Why]
Coverity reports RESOURCE_LEAK for some implemenations
of clock_source_create. Do not release memory of clk_src
if contructor fails.

[How]
Free clk_src if contructor fails.

Reviewed-by: Harry Wentland <[email protected]>
Acked-by: Tom Chung <[email protected]>
Signed-off-by: Hersen Wu <[email protected]>
Tested-by: Daniel Wheeler <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
Hersen Wu authored and gregkh committed Sep 8, 2024
1 parent 44def55 commit 3410838
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,7 @@ struct resource_pool *dce83_create_resource_pool(
if (dce83_construct(num_virtual_links, dc, pool))
return &pool->base;

kfree(pool);
BREAK_TO_DEBUGGER();
return NULL;
}
Original file line number Diff line number Diff line change
Expand Up @@ -1864,6 +1864,7 @@ static struct clock_source *dcn30_clock_source_create(
return &clk_src->base;
}

kfree(clk_src);
BREAK_TO_DEBUGGER();
return NULL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1660,8 +1660,8 @@ static struct clock_source *dcn31_clock_source_create(
return &clk_src->base;
}

BREAK_TO_DEBUGGER();
kfree(clk_src);
BREAK_TO_DEBUGGER();
return NULL;
}

Expand Down Expand Up @@ -1821,8 +1821,8 @@ static struct clock_source *dcn30_clock_source_create(
return &clk_src->base;
}

BREAK_TO_DEBUGGER();
kfree(clk_src);
BREAK_TO_DEBUGGER();
return NULL;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,7 @@ static struct clock_source *dcn35_clock_source_create(
return &clk_src->base;
}

kfree(clk_src);
BREAK_TO_DEBUGGER();
return NULL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1696,6 +1696,7 @@ static struct clock_source *dcn35_clock_source_create(
return &clk_src->base;
}

kfree(clk_src);
BREAK_TO_DEBUGGER();
return NULL;
}
Expand Down

0 comments on commit 3410838

Please sign in to comment.