All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v2] hinic: fix potential resource leak
@ 2020-09-17 12:29 Wei Li
  2020-09-18  0:04 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Li @ 2020-09-17 12:29 UTC (permalink / raw)
  To: Bin Luo, David S. Miller, Jakub Kicinski
  Cc: netdev, linux-kernel, huawei.libin, guohanjun

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 <liwei391@huawei.com>
---
v1 -> v2:
 - Free irq as well when irq_set_affinity_hint() fails.
---
 drivers/net/ethernet/huawei/hinic/hinic_rx.c | 21 +++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/huawei/hinic/hinic_rx.c b/drivers/net/ethernet/huawei/hinic/hinic_rx.c
index 5bee951fe9d4..cc1d425d070c 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_rx.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_rx.c
@@ -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)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net v2] hinic: fix potential resource leak
  2020-09-17 12:29 [PATCH net v2] hinic: fix potential resource leak Wei Li
@ 2020-09-18  0:04 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-09-18  0:04 UTC (permalink / raw)
  To: liwei391; +Cc: luobin9, kuba, netdev, linux-kernel, huawei.libin, guohanjun

From: Wei Li <liwei391@huawei.com>
Date: Thu, 17 Sep 2020 20:29:50 +0800

> 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 <liwei391@huawei.com>
> ---
> v1 -> v2:
>  - Free irq as well when irq_set_affinity_hint() fails.

Applied, thank you.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-18  0:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 12:29 [PATCH net v2] hinic: fix potential resource leak Wei Li
2020-09-18  0:04 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.