amd: use a valid size for ac_pm4_state allocation
If max_dw is smaller than the pm4 array the allocation size would be
smaller than sizeof(ac_pm4_state).
Fixes: 428601095c
("ac,radeonsi import PM4 state from RadeonSI")
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30257>
This commit is contained in:

committed by
Marge Bot

parent
547de1e928
commit
0c868aa94a
@@ -409,7 +409,11 @@ ac_pm4_create_sized(const struct radeon_info *info, bool debug_sqtt,
|
||||
unsigned max_dw, bool is_compute_queue)
|
||||
{
|
||||
struct ac_pm4_state *pm4;
|
||||
unsigned size = sizeof(*pm4) + 4 * (max_dw - ARRAY_SIZE(pm4->pm4));
|
||||
unsigned size;
|
||||
|
||||
max_dw = MAX2(max_dw, ARRAY_SIZE(pm4->pm4));
|
||||
|
||||
size = sizeof(*pm4) + 4 * (max_dw - ARRAY_SIZE(pm4->pm4));
|
||||
|
||||
pm4 = (struct ac_pm4_state *)calloc(1, size);
|
||||
if (pm4) {
|
||||
|
Reference in New Issue
Block a user