Skip to content

Commit

Permalink
cnic: Check device state before reading the kcq pointer in IRQ
Browse files Browse the repository at this point in the history
If the device is down, the kcq pointer may be NULL.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Michael Chan authored and David S. Miller committed Dec 23, 2010
1 parent 4aacb7a commit eaaa6e9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions drivers/net/cnic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2352,11 +2352,12 @@ static u32 cnic_service_bnx2_queues(struct cnic_dev *dev)
static int cnic_service_bnx2(void *data, void *status_blk)
{
struct cnic_dev *dev = data;
struct cnic_local *cp = dev->cnic_priv;
u32 status_idx = *cp->kcq1.status_idx_ptr;

if (unlikely(!test_bit(CNIC_F_CNIC_UP, &dev->flags)))
return status_idx;
if (unlikely(!test_bit(CNIC_F_CNIC_UP, &dev->flags))) {
struct status_block *sblk = status_blk;

return sblk->status_idx;
}

return cnic_service_bnx2_queues(dev);
}
Expand All @@ -2375,9 +2376,10 @@ static void cnic_service_bnx2_msix(unsigned long data)
static void cnic_doirq(struct cnic_dev *dev)
{
struct cnic_local *cp = dev->cnic_priv;
u16 prod = cp->kcq1.sw_prod_idx & MAX_KCQ_IDX;

if (likely(test_bit(CNIC_F_CNIC_UP, &dev->flags))) {
u16 prod = cp->kcq1.sw_prod_idx & MAX_KCQ_IDX;

prefetch(cp->status_blk.gen);
prefetch(&cp->kcq1.kcq[KCQ_PG(prod)][KCQ_IDX(prod)]);

Expand Down

0 comments on commit eaaa6e9

Please sign in to comment.