Skip to content

Commit

Permalink
hinic: fix potential resource leak
Browse files Browse the repository at this point in the history
In rx_request_irq(), it will just return what irq_set_affinity_hint()
returns. If it is failed, the napi and irq requested are not freed
properly. So add exits for failures to handle these.

Signed-off-by: Wei Li <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
stkid authored and davem330 committed Sep 18, 2020
1 parent 0dfdbc7 commit ce000c6
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions drivers/net/ethernet/huawei/hinic/hinic_rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -543,18 +543,25 @@ static int rx_request_irq(struct hinic_rxq *rxq)
if (err) {
netif_err(nic_dev, drv, rxq->netdev,
"Failed to set RX interrupt coalescing attribute\n");
rx_del_napi(rxq);
return err;
goto err_req_irq;
}

err = request_irq(rq->irq, rx_irq, 0, rxq->irq_name, rxq);
if (err) {
rx_del_napi(rxq);
return err;
}
if (err)
goto err_req_irq;

cpumask_set_cpu(qp->q_id % num_online_cpus(), &rq->affinity_mask);
return irq_set_affinity_hint(rq->irq, &rq->affinity_mask);
err = irq_set_affinity_hint(rq->irq, &rq->affinity_mask);
if (err)
goto err_irq_affinity;

return 0;

err_irq_affinity:
free_irq(rq->irq, rxq);
err_req_irq:
rx_del_napi(rxq);
return err;
}

static void rx_free_irq(struct hinic_rxq *rxq)
Expand Down

0 comments on commit ce000c6

Please sign in to comment.