[PATCH v4 10/12] libusbg: Move symlink creation after memory allocation.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Move creation of symlink after memory allocation for
binding structure. Fix missing initialization of parent.
Signed-off-by: Krzysztof Opasiak <k.opasiak@xxxxxxxxxxx>
---
 src/usbg.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/usbg.c b/src/usbg.c
index 0df2f7d..71317f4 100644
--- a/src/usbg.c
+++ b/src/usbg.c
@@ -788,21 +788,22 @@ int usbg_add_config_function(struct config *c, char *name, struct function *f)
 	sprintf(bpath, "%s/%s", c->path, name);
 	sprintf(fpath, "%s/%s", f->path, f->name);
 
-	ret = symlink(fpath, bpath);
-	if (ret < 0) {
-		ERRORNO("%s -> %s\n", bpath, fpath);
-		return ret;
-	}
-
 	b = malloc(sizeof(struct binding));
 	if (!b) {
 		ERRORNO("allocating binding\n");
 		return -1;
 	}
 
+	ret = symlink(fpath, bpath);
+	if (ret < 0) {
+		ERRORNO("%s -> %s\n", bpath, fpath);
+		return ret;
+	}
+
 	strcpy(b->name, name);
 	strcpy(b->path, bpath);
 	b->target = f;
+	b->parent = c;
 
 	/* Insert in string order */
 	if (TAILQ_EMPTY(&c->bindings) ||
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux