aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/infiniband/hw/ipath/ipath_eeprom.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_eeprom.c b/drivers/infiniband/hw/ipath/ipath_eeprom.c
index bcfa3ccb555f..e7c25dbbcdc9 100644
--- a/drivers/infiniband/hw/ipath/ipath_eeprom.c
+++ b/drivers/infiniband/hw/ipath/ipath_eeprom.c
@@ -538,7 +538,15 @@ static u8 flash_csum(struct ipath_flash *ifp, int adjust)
538 u8 *ip = (u8 *) ifp; 538 u8 *ip = (u8 *) ifp;
539 u8 csum = 0, len; 539 u8 csum = 0, len;
540 540
541 for (len = 0; len < ifp->if_length; len++) 541 /*
542 * Limit length checksummed to max length of actual data.
543 * Checksum of erased eeprom will still be bad, but we avoid
544 * reading past the end of the buffer we were passed.
545 */
546 len = ifp->if_length;
547 if (len > sizeof(struct ipath_flash))
548 len = sizeof(struct ipath_flash);
549 while (len--)
542 csum += *ip++; 550 csum += *ip++;
543 csum -= ifp->if_csum; 551 csum -= ifp->if_csum;
544 csum = ~csum; 552 csum = ~csum;