Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 344169
b: refs/heads/master
c: ce8f0d0
h: refs/heads/master
i:
  344167: 2f4bdfa
v: v3
  • Loading branch information
Jonas Gorski authored and John Crispin committed Dec 12, 2012
1 parent d7b7f72 commit c43b6f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 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: 2da4c74dc3711275e82856e62884c99f7a45f541
refs/heads/master: ce8f0d0607bcad3ec0e8599be80353204427093e
23 changes: 13 additions & 10 deletions trunk/arch/mips/bcm63xx/nvram.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define pr_fmt(fmt) "bcm63xx_nvram: " fmt

#include <linux/init.h>
#include <linux/crc32.h>
#include <linux/export.h>
#include <linux/kernel.h>
#include <linux/if_ether.h>
Expand Down Expand Up @@ -40,23 +41,25 @@ static int mac_addr_used;
int __init bcm63xx_nvram_init(void *addr)
{
unsigned int check_len;
u8 *p;
u32 val;
u32 crc, expected_crc;

/* extract nvram data */
memcpy(&nvram, addr, sizeof(nvram));

/* check checksum before using data */
if (nvram.version <= 4)
check_len = offsetof(struct bcm963xx_nvram, checksum_old);
else
if (nvram.version <= 4) {
check_len = offsetof(struct bcm963xx_nvram, reserved3);
expected_crc = nvram.checksum_old;
nvram.checksum_old = 0;
} else {
check_len = sizeof(nvram);
val = 0;
p = (u8 *)&nvram;
expected_crc = nvram.checksum_high;
nvram.checksum_high = 0;
}

crc = crc32_le(~0, (u8 *)&nvram, check_len);

while (check_len--)
val += *p;
if (val)
if (crc != expected_crc)
return -EINVAL;

return 0;
Expand Down

0 comments on commit c43b6f9

Please sign in to comment.