Skip to content

Commit

Permalink
cxgb4: Validate VPD checksum with pci_vpd_check_csum()
Browse files Browse the repository at this point in the history
Validate the VPD checksum with pci_vpd_check_csum() to simplify the code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Heiner Kallweit authored and David S. Miller committed Aug 22, 2021
1 parent 58a9b5d commit 96ce96f
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2745,7 +2745,7 @@ int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p)
{
int i, ret = 0, addr;
int ec, sn, pn, na;
u8 *vpd, csum, base_val = 0;
u8 *vpd, base_val = 0;
unsigned int vpdr_len, kw_offset, id_len;

vpd = vmalloc(VPD_LEN);
Expand Down Expand Up @@ -2800,13 +2800,9 @@ int t4_get_raw_vpd_params(struct adapter *adapter, struct vpd_params *p)
var += PCI_VPD_INFO_FLD_HDR_SIZE; \
} while (0)

FIND_VPD_KW(i, "RV");
for (csum = 0; i >= 0; i--)
csum += vpd[i];

if (csum) {
dev_err(adapter->pdev_dev,
"corrupted VPD EEPROM, actual csum %u\n", csum);
ret = pci_vpd_check_csum(vpd, VPD_LEN);
if (ret) {
dev_err(adapter->pdev_dev, "VPD checksum incorrect or missing\n");
ret = -EINVAL;
goto out;
}
Expand Down

0 comments on commit 96ce96f

Please sign in to comment.