[PATCH 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/gadget.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/gadget.c b/src/gadget.c
index 0554c7d..2bc4f2e 100644
--- a/src/gadget.c
+++ b/src/gadget.c
@@ -789,21 +789,22 @@ int gadget_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