Move creation of symlink after memory allocation for
binding structure. Fix missing initialization of parent.
Signed-off-by: Krzysztof Opasiak <[email protected]>
---
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html