Skip to content

Commit ce000c6

Browse files
stkiddavem330
authored andcommitted
hinic: fix potential resource leak
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]>
1 parent 0dfdbc7 commit ce000c6

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

drivers/net/ethernet/huawei/hinic/hinic_rx.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -543,18 +543,25 @@ static int rx_request_irq(struct hinic_rxq *rxq)
543543
if (err) {
544544
netif_err(nic_dev, drv, rxq->netdev,
545545
"Failed to set RX interrupt coalescing attribute\n");
546-
rx_del_napi(rxq);
547-
return err;
546+
goto err_req_irq;
548547
}
549548

550549
err = request_irq(rq->irq, rx_irq, 0, rxq->irq_name, rxq);
551-
if (err) {
552-
rx_del_napi(rxq);
553-
return err;
554-
}
550+
if (err)
551+
goto err_req_irq;
555552

556553
cpumask_set_cpu(qp->q_id % num_online_cpus(), &rq->affinity_mask);
557-
return irq_set_affinity_hint(rq->irq, &rq->affinity_mask);
554+
err = irq_set_affinity_hint(rq->irq, &rq->affinity_mask);
555+
if (err)
556+
goto err_irq_affinity;
557+
558+
return 0;
559+
560+
err_irq_affinity:
561+
free_irq(rq->irq, rxq);
562+
err_req_irq:
563+
rx_del_napi(rxq);
564+
return err;
558565
}
559566

560567
static void rx_free_irq(struct hinic_rxq *rxq)

0 commit comments

Comments
 (0)