Skip to content

Commit e74313b

Browse files
YiPeng Chaialexdeucher
authored andcommitted
drm/amdgpu: add condition check for amdgpu_umc_fill_error_record
Add condition check for amdgpu_umc_fill_error_record. Signed-off-by: YiPeng Chai <[email protected]> Reviewed-by: Tao Zhou <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 2cf8e50 commit e74313b

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ struct ras_err_data {
579579
unsigned long de_count;
580580
unsigned long err_addr_cnt;
581581
struct eeprom_table_record *err_addr;
582+
unsigned long err_addr_len;
582583
u32 err_list_count;
583584
struct list_head err_node_list;
584585
};

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ int amdgpu_umc_page_retirement_mca(struct amdgpu_device *adev,
6666
goto out_fini_err_data;
6767
}
6868

69+
err_data.err_addr_len = adev->umc.max_ras_err_cnt_per_query;
70+
6971
/*
7072
* Translate UMC channel address to Physical address
7173
*/
@@ -121,6 +123,8 @@ void amdgpu_umc_handle_bad_pages(struct amdgpu_device *adev,
121123
if(!err_data->err_addr)
122124
dev_warn(adev->dev, "Failed to alloc memory for "
123125
"umc error address record!\n");
126+
else
127+
err_data->err_addr_len = adev->umc.max_ras_err_cnt_per_query;
124128

125129
/* umc query_ras_error_address is also responsible for clearing
126130
* error status
@@ -146,6 +150,8 @@ void amdgpu_umc_handle_bad_pages(struct amdgpu_device *adev,
146150
if(!err_data->err_addr)
147151
dev_warn(adev->dev, "Failed to alloc memory for "
148152
"umc error address record!\n");
153+
else
154+
err_data->err_addr_len = adev->umc.max_ras_err_cnt_per_query;
149155

150156
/* umc query_ras_error_address is also responsible for clearing
151157
* error status
@@ -389,14 +395,20 @@ int amdgpu_umc_process_ecc_irq(struct amdgpu_device *adev,
389395
return 0;
390396
}
391397

392-
void amdgpu_umc_fill_error_record(struct ras_err_data *err_data,
398+
int amdgpu_umc_fill_error_record(struct ras_err_data *err_data,
393399
uint64_t err_addr,
394400
uint64_t retired_page,
395401
uint32_t channel_index,
396402
uint32_t umc_inst)
397403
{
398-
struct eeprom_table_record *err_rec =
399-
&err_data->err_addr[err_data->err_addr_cnt];
404+
struct eeprom_table_record *err_rec;
405+
406+
if (!err_data ||
407+
!err_data->err_addr ||
408+
(err_data->err_addr_cnt >= err_data->err_addr_len))
409+
return -EINVAL;
410+
411+
err_rec = &err_data->err_addr[err_data->err_addr_cnt];
400412

401413
err_rec->address = err_addr;
402414
/* page frame address is saved */
@@ -408,6 +420,8 @@ void amdgpu_umc_fill_error_record(struct ras_err_data *err_data,
408420
err_rec->mcumc_id = umc_inst;
409421

410422
err_data->err_addr_cnt++;
423+
424+
return 0;
411425
}
412426

413427
int amdgpu_umc_loop_channels(struct amdgpu_device *adev,

drivers/gpu/drm/amd/amdgpu/amdgpu_umc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ int amdgpu_umc_poison_handler(struct amdgpu_device *adev,
109109
int amdgpu_umc_process_ecc_irq(struct amdgpu_device *adev,
110110
struct amdgpu_irq_src *source,
111111
struct amdgpu_iv_entry *entry);
112-
void amdgpu_umc_fill_error_record(struct ras_err_data *err_data,
112+
int amdgpu_umc_fill_error_record(struct ras_err_data *err_data,
113113
uint64_t err_addr,
114114
uint64_t retired_page,
115115
uint32_t channel_index,

0 commit comments

Comments
 (0)