All of lore.kernel.org
 help / color / mirror / Atom feed
* [Accel-config] [PATCH v1 4/5] accel-config: Add freeing of mdev list
@ 2020-12-08 20:36 ramesh.thomas
  0 siblings, 0 replies; only message in thread
From: ramesh.thomas @ 2020-12-08 20:36 UTC (permalink / raw)
  To: accel-config

[-- Attachment #1: Type: text/plain, Size: 1380 bytes --]

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Per device mdev list was not getting freed at error exit and when device
was getting freed. Add freeing of list for a given device.

Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/lib/libaccfg.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c
index b1e6d86..2b3bbb3 100644
--- a/accfg/lib/libaccfg.c
+++ b/accfg/lib/libaccfg.c
@@ -153,6 +153,16 @@ static char *accfg_get_param_str(struct accfg_ctx *ctx, int dfd, char *name)
 	return strdup(buf);
 }
 
+static void free_mdevs(struct accfg_device *device)
+{
+	struct accfg_device_mdev *mdev, *next;
+
+	list_for_each_safe(&device->mdev_list, mdev, next, list) {
+		list_del_from(&device->mdev_list, &mdev->list);
+		free(mdev);
+	}
+}
+
 static void free_engine(struct accfg_engine *engine)
 {
 	struct accfg_device *device = engine->device;
@@ -195,6 +205,7 @@ static void free_device(struct accfg_device *device, struct list_head *head)
 		free_wq(wq);
 	list_for_each_safe(&device->engines, engine, engine_next, list)
 		free_engine(engine);
+	free_mdevs(device);
 
 	if (head)
 		list_del_from(head, &device->list);
@@ -473,6 +484,9 @@ exit_add_mdev:
 		free(d[n1]);
 	free(d);
 
+	if (rc)
+		free_mdevs(dev);
+
 	return rc;
 }
 
-- 
2.26.2

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-12-08 20:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08 20:36 [Accel-config] [PATCH v1 4/5] accel-config: Add freeing of mdev list ramesh.thomas

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.