* [PATCH 1/3] ibmvnic: Free coherent DMA memory if FW map failed
2018-05-16 20:49 [PATCH 0/3] ibmvnic: Fix bugs and memory leaks Thomas Falcon
@ 2018-05-16 20:49 ` Thomas Falcon
2018-05-16 20:49 ` [PATCH 2/3] ibmvnic: Fix non-fatal firmware error reset Thomas Falcon
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Thomas Falcon @ 2018-05-16 20:49 UTC (permalink / raw)
To: netdev; +Cc: jallen, nfont, Thomas Falcon
If the firmware map fails for whatever reason, remember to free
up the memory after.
Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
---
drivers/net/ethernet/ibm/ibmvnic.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 6e8d6a6..9e08917 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -192,6 +192,7 @@ static int alloc_long_term_buff(struct ibmvnic_adapter *adapter,
if (adapter->fw_done_rc) {
dev_err(dev, "Couldn't map long term buffer,rc = %d\n",
adapter->fw_done_rc);
+ dma_free_coherent(dev, ltb->size, ltb->buff, ltb->addr);
return -1;
}
return 0;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] ibmvnic: Fix non-fatal firmware error reset
2018-05-16 20:49 [PATCH 0/3] ibmvnic: Fix bugs and memory leaks Thomas Falcon
2018-05-16 20:49 ` [PATCH 1/3] ibmvnic: Free coherent DMA memory if FW map failed Thomas Falcon
@ 2018-05-16 20:49 ` Thomas Falcon
2018-05-16 20:49 ` [PATCH 3/3] ibmvnic: Fix statistics buffers memory leak Thomas Falcon
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Thomas Falcon @ 2018-05-16 20:49 UTC (permalink / raw)
To: netdev; +Cc: jallen, nfont, Thomas Falcon
It is not necessary to disable interrupt lines here during a reset
to handle a non-fatal firmware error. Move that call within the code
block that handles the other cases that do require interrupts to be
disabled and re-enabled.
Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
---
drivers/net/ethernet/ibm/ibmvnic.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 9e08917..1b9c22f 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -1822,9 +1822,8 @@ static int do_reset(struct ibmvnic_adapter *adapter,
if (rc)
return rc;
}
+ ibmvnic_disable_irqs(adapter);
}
-
- ibmvnic_disable_irqs(adapter);
adapter->state = VNIC_CLOSED;
if (reset_state == VNIC_CLOSED)
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] ibmvnic: Fix statistics buffers memory leak
2018-05-16 20:49 [PATCH 0/3] ibmvnic: Fix bugs and memory leaks Thomas Falcon
2018-05-16 20:49 ` [PATCH 1/3] ibmvnic: Free coherent DMA memory if FW map failed Thomas Falcon
2018-05-16 20:49 ` [PATCH 2/3] ibmvnic: Fix non-fatal firmware error reset Thomas Falcon
@ 2018-05-16 20:49 ` Thomas Falcon
2018-05-16 20:59 ` [PATCH 0/3] ibmvnic: Fix bugs and memory leaks Thomas Falcon
2018-05-17 18:57 ` David Miller
4 siblings, 0 replies; 6+ messages in thread
From: Thomas Falcon @ 2018-05-16 20:49 UTC (permalink / raw)
To: netdev; +Cc: jallen, nfont, Thomas Falcon
Move initialization of statistics buffers from ibmvnic_init function
into ibmvnic_probe. In the current state, ibmvnic_init will be called
again during a device reset, resulting in the allocation of new
buffers without freeing the old ones.
Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
---
drivers/net/ethernet/ibm/ibmvnic.c | 24 +++++++++++++++---------
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 1b9c22f..4bb4646 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -4586,14 +4586,6 @@ static int ibmvnic_init(struct ibmvnic_adapter *adapter)
release_crq_queue(adapter);
}
- rc = init_stats_buffers(adapter);
- if (rc)
- return rc;
-
- rc = init_stats_token(adapter);
- if (rc)
- return rc;
-
return rc;
}
@@ -4662,13 +4654,21 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
goto ibmvnic_init_fail;
} while (rc == EAGAIN);
+ rc = init_stats_buffers(adapter);
+ if (rc)
+ goto ibmvnic_init_fail;
+
+ rc = init_stats_token(adapter);
+ if (rc)
+ goto ibmvnic_stats_fail;
+
netdev->mtu = adapter->req_mtu - ETH_HLEN;
netdev->min_mtu = adapter->min_mtu - ETH_HLEN;
netdev->max_mtu = adapter->max_mtu - ETH_HLEN;
rc = device_create_file(&dev->dev, &dev_attr_failover);
if (rc)
- goto ibmvnic_init_fail;
+ goto ibmvnic_dev_file_err;
netif_carrier_off(netdev);
rc = register_netdev(netdev);
@@ -4687,6 +4687,12 @@ static int ibmvnic_probe(struct vio_dev *dev, const struct vio_device_id *id)
ibmvnic_register_fail:
device_remove_file(&dev->dev, &dev_attr_failover);
+ibmvnic_dev_file_err:
+ release_stats_token(adapter);
+
+ibmvnic_stats_fail:
+ release_stats_buffers(adapter);
+
ibmvnic_init_fail:
release_sub_crqs(adapter, 1);
release_crq_queue(adapter);
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] ibmvnic: Fix bugs and memory leaks
2018-05-16 20:49 [PATCH 0/3] ibmvnic: Fix bugs and memory leaks Thomas Falcon
` (2 preceding siblings ...)
2018-05-16 20:49 ` [PATCH 3/3] ibmvnic: Fix statistics buffers memory leak Thomas Falcon
@ 2018-05-16 20:59 ` Thomas Falcon
2018-05-17 18:57 ` David Miller
4 siblings, 0 replies; 6+ messages in thread
From: Thomas Falcon @ 2018-05-16 20:59 UTC (permalink / raw)
To: netdev; +Cc: jallen, nfont
On 05/16/2018 03:49 PM, Thomas Falcon wrote:
> This is a small patch series fixing up some bugs and memory leaks
> in the ibmvnic driver. The first fix frees up previously allocated
> memory that should be freed in case of an error. The second fixes
> a reset case that was failing due to TX/RX queue IRQ's being
> erroneously disabled without being enabled again. The final patch
> fixes incorrect reallocated of statistics buffers during a device
> reset, resulting in loss of statistics information and a memory leak.
>
> Thomas Falcon (3):
> ibmvnic: Free coherent DMA memory if FW map failed
> ibmvnic: Fix non-fatal firmware error reset
> ibmvnic: Fix statistics buffers memory leak
Sorry, these are meant for the 'net' tree.
Tom
>
> drivers/net/ethernet/ibm/ibmvnic.c | 28 +++++++++++++++++-----------
> 1 file changed, 17 insertions(+), 11 deletions(-)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] ibmvnic: Fix bugs and memory leaks
2018-05-16 20:49 [PATCH 0/3] ibmvnic: Fix bugs and memory leaks Thomas Falcon
` (3 preceding siblings ...)
2018-05-16 20:59 ` [PATCH 0/3] ibmvnic: Fix bugs and memory leaks Thomas Falcon
@ 2018-05-17 18:57 ` David Miller
4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2018-05-17 18:57 UTC (permalink / raw)
To: tlfalcon; +Cc: netdev, jallen, nfont
From: Thomas Falcon <tlfalcon@linux.vnet.ibm.com>
Date: Wed, 16 May 2018 15:49:02 -0500
> This is a small patch series fixing up some bugs and memory leaks
> in the ibmvnic driver. The first fix frees up previously allocated
> memory that should be freed in case of an error. The second fixes
> a reset case that was failing due to TX/RX queue IRQ's being
> erroneously disabled without being enabled again. The final patch
> fixes incorrect reallocated of statistics buffers during a device
> reset, resulting in loss of statistics information and a memory leak.
Series applied to 'net', thanks Thomas.
^ permalink raw reply [flat|nested] 6+ messages in thread