mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
watchdog: ziirave_wdt: Don't read out more than 'len' firmware bytes
We only compare first 'len' bytes of read firmware, so we don't need to read more that that. Signed-off-by: Andrey Smirnov <[email protected]> Cc: Chris Healy <[email protected]> Cc: Guenter Roeck <[email protected]> Cc: Rick Ramstetter <[email protected]> Cc: [email protected] Cc: [email protected] Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
This commit is contained in:
parent
d91bb8d916
commit
de88053807
1 changed files with 4 additions and 2 deletions
|
|
@ -318,6 +318,8 @@ static int ziirave_firm_verify(struct watchdog_device *wdd,
|
|||
u16 addr;
|
||||
|
||||
for (rec = (void *)fw->data; rec; rec = ihex_next_binrec(rec)) {
|
||||
const u16 len = be16_to_cpu(rec->len);
|
||||
|
||||
addr = (be32_to_cpu(rec->addr) & 0xffff) >> 1;
|
||||
if (addr < ZIIRAVE_FIRM_FLASH_MEMORY_START ||
|
||||
addr > ZIIRAVE_FIRM_FLASH_MEMORY_END)
|
||||
|
|
@ -331,7 +333,7 @@ static int ziirave_firm_verify(struct watchdog_device *wdd,
|
|||
return ret;
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(data); i++) {
|
||||
for (i = 0; i < len; i++) {
|
||||
ret = i2c_smbus_read_byte_data(client,
|
||||
ZIIRAVE_CMD_DOWNLOAD_READ_BYTE);
|
||||
if (ret < 0) {
|
||||
|
|
@ -342,7 +344,7 @@ static int ziirave_firm_verify(struct watchdog_device *wdd,
|
|||
data[i] = ret;
|
||||
}
|
||||
|
||||
if (memcmp(data, rec->data, be16_to_cpu(rec->len))) {
|
||||
if (memcmp(data, rec->data, len)) {
|
||||
dev_err(&client->dev,
|
||||
"Firmware mismatch at address 0x%04x\n", addr);
|
||||
return -EINVAL;
|
||||
|
|
|
|||
Loading…
Reference in a new issue