If we register a device we have to unregister it later when the driver did not accept the device. Also, do not forget to free the backingstore string. Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> --- fs/fs.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-) diff --git a/fs/fs.c b/fs/fs.c index 8f43481..e71d5a2 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -780,8 +780,7 @@ int mount(const char *device, const char *fsname, const char *_path) if (!device) { printf("need a device for driver %s\n", fsname); errno = -ENODEV; - free(fsdev); - goto out; + goto out1; } } safe_strncpy(fsdev->dev.name, fsname, MAX_DRIVER_NAME); @@ -789,16 +788,14 @@ int mount(const char *device, const char *fsname, const char *_path) fsdev->dev.id = get_free_deviceid(fsdev->dev.name); if ((ret = register_device(&fsdev->dev))) { - free(fsdev); errno = ret; - goto out; + goto out1; } if (!fsdev->dev.driver) { /* driver didn't accept the device. Bail out */ - free(fsdev); errno = -EINVAL; - goto out; + goto out2; } if (parent_device) @@ -822,6 +819,16 @@ int mount(const char *device, const char *fsname, const char *_path) e->next = entry; } errno = 0; + + free(path); + return 0; + +out2: + unregister_device(&fsdev->dev); +out1: + if (fsdev->backingstore) + free(fsdev->backingstore); + free(fsdev); out: free(path); return errno; -- 1.7.2.3 _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox