drm/amd/display: Add NULL pointer check for kzalloc
BugLink: https://bugs.launchpad.net/bugs/2101915 commit 8e65a1b7118acf6af96449e1e66b7adbc9396912 upstream. [Why & How] Check return pointer of kzalloc before using it. Reviewed-by: Alex Hung <alex.hung@amd.com> Acked-by: Wayne Lin <wayne.lin@amd.com> Signed-off-by: Hersen Wu <hersenxs.wu@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> [ Resolve minor conflicts ] Signed-off-by: Bin Lan <bin.lan.cn@windriver.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> [koichiroden: from v6.9.9; dropped changes on dcn351_resource.c since K6.8-based Noble doesn't support DCN 3.5.1] CVE-2024-42122 Signed-off-by: Koichiro Den <koichiro.den@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
This commit is contained in:
@@ -560,11 +560,19 @@ void dcn3_clk_mgr_construct(
|
||||
dce_clock_read_ss_info(clk_mgr);
|
||||
|
||||
clk_mgr->base.bw_params = kzalloc(sizeof(*clk_mgr->base.bw_params), GFP_KERNEL);
|
||||
if (!clk_mgr->base.bw_params) {
|
||||
BREAK_TO_DEBUGGER();
|
||||
return;
|
||||
}
|
||||
|
||||
/* need physical address of table to give to PMFW */
|
||||
clk_mgr->wm_range_table = dm_helpers_allocate_gpu_mem(clk_mgr->base.ctx,
|
||||
DC_MEM_ALLOC_TYPE_GART, sizeof(WatermarksExternal_t),
|
||||
&clk_mgr->wm_range_table_addr);
|
||||
if (!clk_mgr->wm_range_table) {
|
||||
BREAK_TO_DEBUGGER();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void dcn3_clk_mgr_destroy(struct clk_mgr_internal *clk_mgr)
|
||||
|
||||
@@ -1176,11 +1176,19 @@ void dcn32_clk_mgr_construct(
|
||||
clk_mgr->smu_present = false;
|
||||
|
||||
clk_mgr->base.bw_params = kzalloc(sizeof(*clk_mgr->base.bw_params), GFP_KERNEL);
|
||||
if (!clk_mgr->base.bw_params) {
|
||||
BREAK_TO_DEBUGGER();
|
||||
return;
|
||||
}
|
||||
|
||||
/* need physical address of table to give to PMFW */
|
||||
clk_mgr->wm_range_table = dm_helpers_allocate_gpu_mem(clk_mgr->base.ctx,
|
||||
DC_MEM_ALLOC_TYPE_GART, sizeof(WatermarksExternal_t),
|
||||
&clk_mgr->wm_range_table_addr);
|
||||
if (!clk_mgr->wm_range_table) {
|
||||
BREAK_TO_DEBUGGER();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void dcn32_clk_mgr_destroy(struct clk_mgr_internal *clk_mgr)
|
||||
|
||||
@@ -2050,6 +2050,9 @@ bool dcn30_validate_bandwidth(struct dc *dc,
|
||||
|
||||
BW_VAL_TRACE_COUNT();
|
||||
|
||||
if (!pipes)
|
||||
goto validate_fail;
|
||||
|
||||
DC_FP_START();
|
||||
out = dcn30_internal_validate_bw(dc, context, pipes, &pipe_cnt, &vlevel, fast_validate, true);
|
||||
DC_FP_END();
|
||||
|
||||
@@ -1311,6 +1311,8 @@ static struct hpo_dp_link_encoder *dcn31_hpo_dp_link_encoder_create(
|
||||
|
||||
/* allocate HPO link encoder */
|
||||
hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_link_encoder), GFP_KERNEL);
|
||||
if (!hpo_dp_enc31)
|
||||
return NULL; /* out of memory */
|
||||
|
||||
hpo_dp_link_encoder31_construct(hpo_dp_enc31, ctx, inst,
|
||||
&hpo_dp_link_enc_regs[inst],
|
||||
@@ -1767,6 +1769,9 @@ bool dcn31_validate_bandwidth(struct dc *dc,
|
||||
|
||||
BW_VAL_TRACE_COUNT();
|
||||
|
||||
if (!pipes)
|
||||
goto validate_fail;
|
||||
|
||||
DC_FP_START();
|
||||
out = dcn30_internal_validate_bw(dc, context, pipes, &pipe_cnt, &vlevel, fast_validate, true);
|
||||
DC_FP_END();
|
||||
|
||||
@@ -1384,6 +1384,8 @@ static struct hpo_dp_link_encoder *dcn31_hpo_dp_link_encoder_create(
|
||||
|
||||
/* allocate HPO link encoder */
|
||||
hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_link_encoder), GFP_KERNEL);
|
||||
if (!hpo_dp_enc31)
|
||||
return NULL; /* out of memory */
|
||||
|
||||
hpo_dp_link_encoder31_construct(hpo_dp_enc31, ctx, inst,
|
||||
&hpo_dp_link_enc_regs[inst],
|
||||
@@ -1744,6 +1746,9 @@ bool dcn314_validate_bandwidth(struct dc *dc,
|
||||
|
||||
BW_VAL_TRACE_COUNT();
|
||||
|
||||
if (!pipes)
|
||||
goto validate_fail;
|
||||
|
||||
if (filter_modes_for_single_channel_workaround(dc, context))
|
||||
goto validate_fail;
|
||||
|
||||
|
||||
@@ -1309,6 +1309,8 @@ static struct hpo_dp_link_encoder *dcn31_hpo_dp_link_encoder_create(
|
||||
|
||||
/* allocate HPO link encoder */
|
||||
hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_link_encoder), GFP_KERNEL);
|
||||
if (!hpo_dp_enc31)
|
||||
return NULL; /* out of memory */
|
||||
|
||||
hpo_dp_link_encoder31_construct(hpo_dp_enc31, ctx, inst,
|
||||
&hpo_dp_link_enc_regs[inst],
|
||||
|
||||
@@ -1306,6 +1306,8 @@ static struct hpo_dp_link_encoder *dcn31_hpo_dp_link_encoder_create(
|
||||
|
||||
/* allocate HPO link encoder */
|
||||
hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_link_encoder), GFP_KERNEL);
|
||||
if (!hpo_dp_enc31)
|
||||
return NULL; /* out of memory */
|
||||
|
||||
hpo_dp_link_encoder31_construct(hpo_dp_enc31, ctx, inst,
|
||||
&hpo_dp_link_enc_regs[inst],
|
||||
|
||||
@@ -1304,6 +1304,8 @@ static struct hpo_dp_link_encoder *dcn32_hpo_dp_link_encoder_create(
|
||||
|
||||
/* allocate HPO link encoder */
|
||||
hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_link_encoder), GFP_KERNEL);
|
||||
if (!hpo_dp_enc31)
|
||||
return NULL; /* out of memory */
|
||||
|
||||
#undef REG_STRUCT
|
||||
#define REG_STRUCT hpo_dp_link_enc_regs
|
||||
@@ -1757,6 +1759,9 @@ static bool dml1_validate(struct dc *dc, struct dc_state *context, bool fast_val
|
||||
|
||||
BW_VAL_TRACE_COUNT();
|
||||
|
||||
if (!pipes)
|
||||
goto validate_fail;
|
||||
|
||||
DC_FP_START();
|
||||
out = dcn32_internal_validate_bw(dc, context, pipes, &pipe_cnt, &vlevel, fast_validate);
|
||||
DC_FP_END();
|
||||
|
||||
@@ -1288,6 +1288,8 @@ static struct hpo_dp_link_encoder *dcn321_hpo_dp_link_encoder_create(
|
||||
|
||||
/* allocate HPO link encoder */
|
||||
hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_link_encoder), GFP_KERNEL);
|
||||
if (!hpo_dp_enc31)
|
||||
return NULL; /* out of memory */
|
||||
|
||||
#undef REG_STRUCT
|
||||
#define REG_STRUCT hpo_dp_link_enc_regs
|
||||
|
||||
@@ -1368,6 +1368,8 @@ static struct hpo_dp_link_encoder *dcn31_hpo_dp_link_encoder_create(
|
||||
|
||||
/* allocate HPO link encoder */
|
||||
hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_link_encoder), GFP_KERNEL);
|
||||
if (!hpo_dp_enc31)
|
||||
return NULL; /* out of memory */
|
||||
|
||||
#undef REG_STRUCT
|
||||
#define REG_STRUCT hpo_dp_link_enc_regs
|
||||
|
||||
Reference in New Issue
Block a user