radeon_hd: fix typecast in atombios table header parser
* The pointer mdt should point to the start of the contents of the master data table. As defined in struct ATOM_MASTER_DATA_TABLE, the content begins 4 bytes after the beginning of the table (which in turn is ctx->data_table bytes from the start of the AtomBIOS). The wrong parantheses in the cast moved the pointer somewhere else completely. * That this apparently worked on many cards is because the mdt pointer in this function is used just to make sure that the following dereference is not a NULL-pointer access. The actual dereference is then done using the CU16() and CU8() macros which do the casts correctly. However, it only worked when the wrong pointer plus index lead to some byte which was, by chance, not zero. For many chips, this was the case. * For the AtomBIOS of a Radeon HD7850M (Heathrow Pro) it didn't work out though and the driver couldn't parse tables. With this fix, it now works on such chips as well. * Also, fix the same problem in code for master command table.
This commit is contained in:
@@ -1348,7 +1348,7 @@ atom_parse_data_header(atom_context *ctx, int index, uint16 *size,
|
||||
{
|
||||
int offset = index * 2 + 4;
|
||||
int idx = CU16(ctx->data_table + offset);
|
||||
uint16 *mdt = (uint16 *)ctx->bios + ctx->data_table + 4;
|
||||
uint16 *mdt = (uint16*)(ctx->bios + ctx->data_table + 4);
|
||||
|
||||
if (!mdt[index])
|
||||
return B_ERROR;
|
||||
@@ -1370,7 +1370,7 @@ atom_parse_cmd_header(atom_context *ctx, int index, uint8 * frev,
|
||||
{
|
||||
int offset = index * 2 + 4;
|
||||
int idx = CU16(ctx->cmd_table + offset);
|
||||
uint16 *mct = (uint16 *)ctx->bios + ctx->cmd_table + 4;
|
||||
uint16 *mct = (uint16*)(ctx->bios + ctx->cmd_table + 4);
|
||||
|
||||
if (!mct[index])
|
||||
return B_ERROR;
|
||||
|
||||
Reference in New Issue
Block a user