Skip to content

Commit

Permalink
ionic: check for NULL structs on teardown
Browse files Browse the repository at this point in the history
Make sure the queue structs exist before trying to tear
them down to make for safer error recovery.

Fixes: 0f3154e ("ionic: Add Tx and Rx handling")
Signed-off-by: Shannon Nelson <snelson@pensando.io>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Shannon Nelson authored and David S. Miller committed Mar 22, 2020
1 parent b9c17d3 commit a4674f3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
26 changes: 14 additions & 12 deletions drivers/net/ethernet/pensando/ionic/ionic_lif.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,19 +320,21 @@ static void ionic_qcqs_free(struct ionic_lif *lif)
lif->adminqcq = NULL;
}

for (i = 0; i < lif->nxqs; i++)
if (lif->rxqcqs[i].stats)
devm_kfree(dev, lif->rxqcqs[i].stats);

devm_kfree(dev, lif->rxqcqs);
lif->rxqcqs = NULL;

for (i = 0; i < lif->nxqs; i++)
if (lif->txqcqs[i].stats)
devm_kfree(dev, lif->txqcqs[i].stats);
if (lif->rxqcqs) {
for (i = 0; i < lif->nxqs; i++)
if (lif->rxqcqs[i].stats)
devm_kfree(dev, lif->rxqcqs[i].stats);
devm_kfree(dev, lif->rxqcqs);
lif->rxqcqs = NULL;
}

devm_kfree(dev, lif->txqcqs);
lif->txqcqs = NULL;
if (lif->txqcqs) {
for (i = 0; i < lif->nxqs; i++)
if (lif->txqcqs[i].stats)
devm_kfree(dev, lif->txqcqs[i].stats);
devm_kfree(dev, lif->txqcqs);
lif->txqcqs = NULL;
}
}

static void ionic_link_qcq_interrupts(struct ionic_qcq *src_qcq,
Expand Down
7 changes: 6 additions & 1 deletion drivers/net/ethernet/pensando/ionic/ionic_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,11 +243,16 @@ static void ionic_adminq_cb(struct ionic_queue *q,

static int ionic_adminq_post(struct ionic_lif *lif, struct ionic_admin_ctx *ctx)
{
struct ionic_queue *adminq = &lif->adminqcq->q;
struct ionic_queue *adminq;
int err = 0;

WARN_ON(in_interrupt());

if (!lif->adminqcq)
return -EIO;

adminq = &lif->adminqcq->q;

spin_lock(&lif->adminq_lock);
if (!ionic_q_has_space(adminq, 1)) {
err = -ENOSPC;
Expand Down

0 comments on commit a4674f3

Please sign in to comment.