DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] bus: fix leak for devices without driver
@ 2023-01-07 15:12 Volodymyr Fialko
  2023-02-07 13:48 ` David Marchand
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Volodymyr Fialko @ 2023-01-07 15:12 UTC (permalink / raw)
  To: dev, Bruce Richardson, Kevin Laatz, Morten Brørup
  Cc: jerinj, Volodymyr Fialko

For devices not assigned to any driver, we leak a pci device object since
it is never freed from the PCI bus device list, reported by ASAN.

Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown")

Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
---
 drivers/bus/pci/pci_common.c | 3 ++-
 drivers/bus/vdev/vdev.c      | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index bc3a7f39fe..e32a9d517a 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -448,7 +448,7 @@ pci_cleanup(void)
 		int ret = 0;
 
 		if (drv == NULL || drv->remove == NULL)
-			continue;
+			goto free;
 
 		ret = drv->remove(dev);
 		if (ret < 0) {
@@ -458,6 +458,7 @@ pci_cleanup(void)
 		dev->driver = NULL;
 		dev->device.driver = NULL;
 
+free:
 		/* free interrupt handles */
 		rte_intr_instance_free(dev->intr_handle);
 		dev->intr_handle = NULL;
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index 41bc07dde7..7974b27295 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -578,18 +578,19 @@ vdev_cleanup(void)
 		int ret = 0;
 
 		if (dev->device.driver == NULL)
-			continue;
+			goto free;
 
 		drv = container_of(dev->device.driver, const struct rte_vdev_driver, driver);
 
 		if (drv->remove == NULL)
-			continue;
+			goto free;
 
 		ret = drv->remove(dev);
 		if (ret < 0)
 			error = -1;
 
 		dev->device.driver = NULL;
+free:
 		free(dev);
 	}
 
-- 
2.34.1


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

* Re: [PATCH] bus: fix leak for devices without driver
  2023-01-07 15:12 [PATCH] bus: fix leak for devices without driver Volodymyr Fialko
@ 2023-02-07 13:48 ` David Marchand
  2023-02-08 11:30 ` Kevin Laatz
  2023-02-09 13:22 ` [PATCH v2] " Volodymyr Fialko
  2 siblings, 0 replies; 6+ messages in thread
From: David Marchand @ 2023-02-07 13:48 UTC (permalink / raw)
  To: Volodymyr Fialko, Kevin Laatz
  Cc: dev, Bruce Richardson, Morten Brørup, jerinj

On Sat, Jan 7, 2023 at 4:12 PM Volodymyr Fialko <vfialko@marvell.com> wrote:
>
> For devices not assigned to any driver, we leak a pci device object since
> it is never freed from the PCI bus device list, reported by ASAN.
>
> Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown")

Worth copying stable.

>
> Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>

At a quick glance, the fix lgtm.
Kevin, can you double check this fix thoroughly?

Thanks.


-- 
David Marchand


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

* Re: [PATCH] bus: fix leak for devices without driver
  2023-01-07 15:12 [PATCH] bus: fix leak for devices without driver Volodymyr Fialko
  2023-02-07 13:48 ` David Marchand
@ 2023-02-08 11:30 ` Kevin Laatz
  2023-02-09 13:22 ` [PATCH v2] " Volodymyr Fialko
  2 siblings, 0 replies; 6+ messages in thread
From: Kevin Laatz @ 2023-02-08 11:30 UTC (permalink / raw)
  To: Volodymyr Fialko, dev, Bruce Richardson, Morten Brørup; +Cc: jerinj

Hi Volodymyr,

On 07/01/2023 15:12, Volodymyr Fialko wrote:
> For devices not assigned to any driver, we leak a pci device object since
> it is never freed from the PCI bus device list, reported by ASAN.
>
> Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown")
>
> Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> ---
>   drivers/bus/pci/pci_common.c | 3 ++-
>   drivers/bus/vdev/vdev.c      | 5 +++--
>   2 files changed, 5 insertions(+), 3 deletions(-)
>
This fix LGTM, but its tricky to reproduce so I have not been able to 
test this.

Could you add some more text to the commit message describing the issue 
and fix, please?

/Kevin


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

* [PATCH v2] bus: fix leak for devices without driver
  2023-01-07 15:12 [PATCH] bus: fix leak for devices without driver Volodymyr Fialko
  2023-02-07 13:48 ` David Marchand
  2023-02-08 11:30 ` Kevin Laatz
@ 2023-02-09 13:22 ` Volodymyr Fialko
  2023-02-10  9:28   ` Kevin Laatz
  2 siblings, 1 reply; 6+ messages in thread
From: Volodymyr Fialko @ 2023-02-09 13:22 UTC (permalink / raw)
  To: dev, Bruce Richardson, Kevin Laatz, Morten Brørup
  Cc: jerinj, david.marchand, Volodymyr Fialko, stable

During the bus scan, memory for device configuration is allocated.
Currently, if a driver wasn't attached to the device during initialization,
memory for that device will not be released at bus cleanup.
This patch address this issue and releases the memory for all allocated
devices.

Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown")
Cc: stable@dpdk.org

Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
---
V2:
- Updated commit message.

 drivers/bus/pci/pci_common.c | 3 ++-
 drivers/bus/vdev/vdev.c      | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c
index e0e15fd624..3b4196a43b 100644
--- a/drivers/bus/pci/pci_common.c
+++ b/drivers/bus/pci/pci_common.c
@@ -450,7 +450,7 @@ pci_cleanup(void)
 		int ret = 0;
 
 		if (drv == NULL || drv->remove == NULL)
-			continue;
+			goto free;
 
 		ret = drv->remove(dev);
 		if (ret < 0) {
@@ -460,6 +460,7 @@ pci_cleanup(void)
 		dev->driver = NULL;
 		dev->device.driver = NULL;
 
+free:
 		/* free interrupt handles */
 		rte_intr_instance_free(dev->intr_handle);
 		dev->intr_handle = NULL;
diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c
index 41bc07dde7..7974b27295 100644
--- a/drivers/bus/vdev/vdev.c
+++ b/drivers/bus/vdev/vdev.c
@@ -578,18 +578,19 @@ vdev_cleanup(void)
 		int ret = 0;
 
 		if (dev->device.driver == NULL)
-			continue;
+			goto free;
 
 		drv = container_of(dev->device.driver, const struct rte_vdev_driver, driver);
 
 		if (drv->remove == NULL)
-			continue;
+			goto free;
 
 		ret = drv->remove(dev);
 		if (ret < 0)
 			error = -1;
 
 		dev->device.driver = NULL;
+free:
 		free(dev);
 	}
 
-- 
2.34.1


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

* Re: [PATCH v2] bus: fix leak for devices without driver
  2023-02-09 13:22 ` [PATCH v2] " Volodymyr Fialko
@ 2023-02-10  9:28   ` Kevin Laatz
  2023-02-10 11:55     ` David Marchand
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Laatz @ 2023-02-10  9:28 UTC (permalink / raw)
  To: Volodymyr Fialko, dev, Bruce Richardson, Morten Brørup
  Cc: jerinj, david.marchand, stable

On 09/02/2023 13:22, Volodymyr Fialko wrote:
> During the bus scan, memory for device configuration is allocated.
> Currently, if a driver wasn't attached to the device during initialization,
> memory for that device will not be released at bus cleanup.
> This patch address this issue and releases the memory for all allocated
> devices.
>
> Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown")
> Cc: stable@dpdk.org
>
> Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> ---
> V2:
> - Updated commit message.
>
>   drivers/bus/pci/pci_common.c | 3 ++-
>   drivers/bus/vdev/vdev.c      | 5 +++--
>   2 files changed, 5 insertions(+), 3 deletions(-)
>
Acked-by: Kevin Laatz <kevin.laatz@intel.com>

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

* Re: [PATCH v2] bus: fix leak for devices without driver
  2023-02-10  9:28   ` Kevin Laatz
@ 2023-02-10 11:55     ` David Marchand
  0 siblings, 0 replies; 6+ messages in thread
From: David Marchand @ 2023-02-10 11:55 UTC (permalink / raw)
  To: Volodymyr Fialko
  Cc: Kevin Laatz, dev, Bruce Richardson, Morten Brørup, jerinj, stable

On Fri, Feb 10, 2023 at 10:29 AM Kevin Laatz <kevin.laatz@intel.com> wrote:
>
> On 09/02/2023 13:22, Volodymyr Fialko wrote:
> > During the bus scan, memory for device configuration is allocated.
> > Currently, if a driver wasn't attached to the device during initialization,
> > memory for that device will not be released at bus cleanup.
> > This patch address this issue and releases the memory for all allocated
> > devices.
> >
> > Fixes: 1cab1a40ea9b ("bus: cleanup devices on shutdown")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> Acked-by: Kevin Laatz <kevin.laatz@intel.com>

Applied, thanks.


-- 
David Marchand


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

end of thread, other threads:[~2023-02-10 11:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-07 15:12 [PATCH] bus: fix leak for devices without driver Volodymyr Fialko
2023-02-07 13:48 ` David Marchand
2023-02-08 11:30 ` Kevin Laatz
2023-02-09 13:22 ` [PATCH v2] " Volodymyr Fialko
2023-02-10  9:28   ` Kevin Laatz
2023-02-10 11:55     ` David Marchand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).