Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 255591
b: refs/heads/master
c: 960aee6
h: refs/heads/master
i:
  255589: 5a25aef
  255587: 8969090
  255583: 1f4a29d
v: v3
  • Loading branch information
Hayes Wang authored and Francois Romieu committed Jun 18, 2011
1 parent d17ceda commit e5bb788
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1c361efb226d609a07403057a71557faf500b17a
refs/heads/master: 960aee6c7d5951ac20c0227ad73bad56392f0afc
36 changes: 35 additions & 1 deletion trunk/drivers/net/r8169.c
Original file line number Diff line number Diff line change
Expand Up @@ -1754,18 +1754,52 @@ static void rtl_writephy_batch(struct rtl8169_private *tp,
#define PHY_DELAY_MS 0xe0000000
#define PHY_WRITE_ERI_WORD 0xf0000000

struct fw_info {
u32 magic;
char version[RTL_VER_SIZE];
__le32 fw_start;
__le32 fw_len;
u8 chksum;
} __packed;

#define FW_OPCODE_SIZE sizeof(typeof(*((struct rtl_fw_phy_action *)0)->code))

static bool rtl_fw_format_ok(struct rtl8169_private *tp, struct rtl_fw *rtl_fw)
{
const struct firmware *fw = rtl_fw->fw;
struct fw_info *fw_info = (struct fw_info *)fw->data;
struct rtl_fw_phy_action *pa = &rtl_fw->phy_action;
char *version = rtl_fw->version;
bool rc = false;

if (fw->size < FW_OPCODE_SIZE)
goto out;
else {

if (!fw_info->magic) {
size_t i, size, start;
u8 checksum = 0;

if (fw->size < sizeof(*fw_info))
goto out;

for (i = 0; i < fw->size; i++)
checksum += fw->data[i];
if (checksum != 0)
goto out;

start = le32_to_cpu(fw_info->fw_start);
if (start > fw->size)
goto out;

size = le32_to_cpu(fw_info->fw_len);
if (size > (fw->size - start) / FW_OPCODE_SIZE)
goto out;

memcpy(version, fw_info->version, RTL_VER_SIZE);

pa->code = (__le32 *)(fw->data + start);
pa->size = size;
} else {
if (fw->size % FW_OPCODE_SIZE)
goto out;

Expand Down

0 comments on commit e5bb788

Please sign in to comment.