summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2011-04-08 12:28:08 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2011-04-11 12:36:26 +0200
commit77e8307b322085f838bcc3dd523436d5925ba664 (patch)
treebb6b9313e96ed26693b4fbb1240e63b8d11e96d3 /fs
parent7c15f466dfe74bcc384889ada065592a9447d8a6 (diff)
downloadbarebox-77e8307b322085f838bcc3dd523436d5925ba664.tar.gz
barebox-77e8307b322085f838bcc3dd523436d5925ba664.tar.xz
fs mount: fix error handling
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@pengutronix.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/fs.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/fs/fs.c b/fs/fs.c
index 8f43481712..e71d5a29af 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;