aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorVladislav Zolotarov <vladz@broadcom.com>2010-04-18 21:13:49 -0400
committerDavid S. Miller <davem@davemloft.net>2010-04-19 16:17:07 -0400
commit2145a92057a94d2d1e3e9674fe03774cda7455ad (patch)
treed341b038d9233101f5a10ef8772748582eb97265 /drivers/net
parent02e3c6cb3f09ac10a1f16d16cf31c8ecaafd2c67 (diff)
bnx2x: Protect code with NOMCP
Don't run code that can't be run if MCP is not present. This will prevent NULL pointer dereferencing. Signed-off-by: Vladislav Zolotarov <vladz@broadcom.com> Signed-off-by: Eilon Greenstein <eilong@broadcom.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/bnx2x_main.c44
1 files changed, 32 insertions, 12 deletions
diff --git a/drivers/net/bnx2x_main.c b/drivers/net/bnx2x_main.c
index 3325592e5da..22fbc4a1b36 100644
--- a/drivers/net/bnx2x_main.c
+++ b/drivers/net/bnx2x_main.c
@@ -513,6 +513,10 @@ static void bnx2x_fw_dump(struct bnx2x *bp)
513 __be32 data[9]; 513 __be32 data[9];
514 int word; 514 int word;
515 515
516 if (BP_NOMCP(bp)) {
517 BNX2X_ERR("NO MCP - can not dump\n");
518 return;
519 }
516 mark = REG_RD(bp, MCP_REG_MCPR_SCRATCH + 0xf104); 520 mark = REG_RD(bp, MCP_REG_MCPR_SCRATCH + 0xf104);
517 mark = ((mark + 0x3) & ~0x3); 521 mark = ((mark + 0x3) & ~0x3);
518 pr_err("begin fw dump (mark 0x%x)\n", mark); 522 pr_err("begin fw dump (mark 0x%x)\n", mark);
@@ -2292,11 +2296,14 @@ static void bnx2x__link_reset(struct bnx2x *bp)
2292 2296
2293static u8 bnx2x_link_test(struct bnx2x *bp) 2297static u8 bnx2x_link_test(struct bnx2x *bp)
2294{ 2298{
2295 u8 rc; 2299 u8 rc = 0;
2296 2300
2297 bnx2x_acquire_phy_lock(bp); 2301 if (!BP_NOMCP(bp)) {
2298 rc = bnx2x_test_link(&bp->link_params, &bp->link_vars); 2302 bnx2x_acquire_phy_lock(bp);
2299 bnx2x_release_phy_lock(bp); 2303 rc = bnx2x_test_link(&bp->link_params, &bp->link_vars);
2304 bnx2x_release_phy_lock(bp);
2305 } else
2306 BNX2X_ERR("Bootcode is missing - can not test link\n");
2300 2307
2301 return rc; 2308 return rc;
2302} 2309}
@@ -4288,7 +4295,6 @@ static int bnx2x_hw_stats_update(struct bnx2x *bp)
4288 u32 lo; 4295 u32 lo;
4289 u32 hi; 4296 u32 hi;
4290 } diff; 4297 } diff;
4291 u32 nig_timer_max;
4292 4298
4293 if (bp->link_vars.mac_type == MAC_TYPE_BMAC) 4299 if (bp->link_vars.mac_type == MAC_TYPE_BMAC)
4294 bnx2x_bmac_stats_update(bp); 4300 bnx2x_bmac_stats_update(bp);
@@ -4319,10 +4325,14 @@ static int bnx2x_hw_stats_update(struct bnx2x *bp)
4319 4325
4320 pstats->host_port_stats_start = ++pstats->host_port_stats_end; 4326 pstats->host_port_stats_start = ++pstats->host_port_stats_end;
4321 4327
4322 nig_timer_max = SHMEM_RD(bp, port_mb[BP_PORT(bp)].stat_nig_timer); 4328 if (!BP_NOMCP(bp)) {
4323 if (nig_timer_max != estats->nig_timer_max) { 4329 u32 nig_timer_max =
4324 estats->nig_timer_max = nig_timer_max; 4330 SHMEM_RD(bp, port_mb[BP_PORT(bp)].stat_nig_timer);
4325 BNX2X_ERR("NIG timer max (%u)\n", estats->nig_timer_max); 4331 if (nig_timer_max != estats->nig_timer_max) {
4332 estats->nig_timer_max = nig_timer_max;
4333 BNX2X_ERR("NIG timer max (%u)\n",
4334 estats->nig_timer_max);
4335 }
4326 } 4336 }
4327 4337
4328 return 0; 4338 return 0;
@@ -6377,10 +6387,14 @@ static void bnx2x_init_pxp(struct bnx2x *bp)
6377 6387
6378static void bnx2x_setup_fan_failure_detection(struct bnx2x *bp) 6388static void bnx2x_setup_fan_failure_detection(struct bnx2x *bp)
6379{ 6389{
6390 int is_required;
6380 u32 val; 6391 u32 val;
6381 u8 port; 6392 int port;
6382 u8 is_required = 0;
6383 6393
6394 if (BP_NOMCP(bp))
6395 return;
6396
6397 is_required = 0;
6384 val = SHMEM_RD(bp, dev_info.shared_hw_config.config2) & 6398 val = SHMEM_RD(bp, dev_info.shared_hw_config.config2) &
6385 SHARED_HW_CFG_FAN_FAILURE_MASK; 6399 SHARED_HW_CFG_FAN_FAILURE_MASK;
6386 6400
@@ -9688,7 +9702,7 @@ static int __devinit bnx2x_get_hwinfo(struct bnx2x *bp)
9688 9702
9689 bp->e1hov = 0; 9703 bp->e1hov = 0;
9690 bp->e1hmf = 0; 9704 bp->e1hmf = 0;
9691 if (CHIP_IS_E1H(bp)) { 9705 if (CHIP_IS_E1H(bp) && !BP_NOMCP(bp)) {
9692 bp->mf_config = 9706 bp->mf_config =
9693 SHMEM_RD(bp, mf_cfg.func_mf_config[func].config); 9707 SHMEM_RD(bp, mf_cfg.func_mf_config[func].config);
9694 9708
@@ -11293,6 +11307,9 @@ static int bnx2x_test_loopback(struct bnx2x *bp, u8 link_up)
11293{ 11307{
11294 int rc = 0, res; 11308 int rc = 0, res;
11295 11309
11310 if (BP_NOMCP(bp))
11311 return rc;
11312
11296 if (!netif_running(bp->dev)) 11313 if (!netif_running(bp->dev))
11297 return BNX2X_LOOPBACK_FAILED; 11314 return BNX2X_LOOPBACK_FAILED;
11298 11315
@@ -11340,6 +11357,9 @@ static int bnx2x_test_nvram(struct bnx2x *bp)
11340 int i, rc; 11357 int i, rc;
11341 u32 magic, crc; 11358 u32 magic, crc;
11342 11359
11360 if (BP_NOMCP(bp))
11361 return 0;
11362
11343 rc = bnx2x_nvram_read(bp, 0, data, 4); 11363 rc = bnx2x_nvram_read(bp, 0, data, 4);
11344 if (rc) { 11364 if (rc) {
11345 DP(NETIF_MSG_PROBE, "magic value read (rc %d)\n", rc); 11365 DP(NETIF_MSG_PROBE, "magic value read (rc %d)\n", rc);