bnx2x: Prevent probe as early as possible
authorYuval Mintz <Yuval.Mintz@qlogic.com>
Sun, 29 Mar 2015 07:05:01 +0000 (10:05 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 31 Mar 2015 17:34:10 +0000 (13:34 -0400)
It's possible that due to errors [either on PCI or on device itself]
registers reads would fail, returning all-Fs.

This adds a check as early as possible so that driver will not read junk
values and make incorrect probe decisions according to them; instead,
gracefully fail the probe.

Signed-off-by: Yuval Mintz <Yuval.Mintz@qlogic.com>
Signed-off-by: Ariel Elior <Ariel.Elior@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c

index 8120d266e068f439b2dc6ad4b34a196ac3753527..768dfb16bc80d42117e978d34a82c6ded4658929 100644 (file)
@@ -11650,6 +11650,13 @@ static int bnx2x_get_hwinfo(struct bnx2x *bp)
        u32 val = 0, val2 = 0;
        int rc = 0;
 
+       /* Validate that chip access is feasible */
+       if (REG_RD(bp, MISC_REG_CHIP_NUM) == 0xffffffff) {
+               dev_err(&bp->pdev->dev,
+                       "Chip read returns all Fs. Preventing probe from continuing\n");
+               return -EINVAL;
+       }
+
        bnx2x_get_common_hwinfo(bp);
 
        /*