All of lore.kernel.org
 help / color / mirror / Atom feed
* [Accel-config] [PATCH v2 2/5] accel-config: Fix a segmentation fault issue in add device
@ 2020-12-08 21:16 ramesh.thomas
  0 siblings, 0 replies; only message in thread
From: ramesh.thomas @ 2020-12-08 21:16 UTC (permalink / raw)
  To: accel-config

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

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

During device init, newly created device should be added to device
linked list only at the end in the success path. Adding of mdev was
done after that, resulting in invalid linked list state if the mdev
scanning failed causing the add device function to fail. Move it before
adding device to linked list.

Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
Reviewed-by: Dave Jiang <dave.jiang(a)intel.com>
---
 accfg/lib/libaccfg.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c
index eda6b45..5835129 100644
--- a/accfg/lib/libaccfg.c
+++ b/accfg/lib/libaccfg.c
@@ -568,12 +568,13 @@ static void *add_device(void *parent, int id, const char *ctl_base, char *dev_pr
 	rc = device_parse_type(device);
 	if (rc < 0)
 		goto err_dev_path;
-	list_add_tail(&ctx->devices, &device->list);
-	free(path);
 
 	if (add_device_mdevs(ctx, device))
 		goto err_dev_path;
 
+	list_add_tail(&ctx->devices, &device->list);
+	free(path);
+
 	return device;
 
 err_dev_path:
-- 
2.26.2

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

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

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08 21:16 [Accel-config] [PATCH v2 2/5] accel-config: Fix a segmentation fault issue in add device 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.