summaryrefslogtreecommitdiffstats
path: root/fs/fat
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-03-18 13:28:45 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2012-03-18 15:03:31 +0100
commit38a1971e5b8ad7f30722d84e74152c980338fbdb (patch)
tree086f794d6d4fa1fc1d83b144fe709be63ad60938 /fs/fat
parentd94579abaf961fcad03cbd0468d0439752d2d206 (diff)
downloadbarebox-38a1971e5b8ad7f30722d84e74152c980338fbdb.tar.gz
barebox-38a1971e5b8ad7f30722d84e74152c980338fbdb.tar.xz
FAT: Fix error path
- forward the return value of chk_mounted to detect whether mount succeeded - free resources on mount failure Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'fs/fat')
-rw-r--r--fs/fat/fat.c18
-rw-r--r--fs/fat/ff.c4
2 files changed, 16 insertions, 6 deletions
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 7d6e37a6b0..21464bde95 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -376,6 +376,7 @@ static int fat_probe(struct device_d *dev)
struct fs_device_d *fsdev = dev_to_fs_device(dev);
struct fat_priv *priv = xzalloc(sizeof(struct fat_priv));
char *backingstore = fsdev->backingstore;
+ int ret;
dev->priv = priv;
@@ -383,13 +384,24 @@ static int fat_probe(struct device_d *dev)
backingstore += 5;
priv->cdev = cdev_open(backingstore, O_RDWR);
- if (!priv->cdev)
- return -EINVAL;
+ if (!priv->cdev) {
+ ret = -ENOENT;
+ goto err_open;
+ }
priv->fat.userdata = priv;
- f_mount(&priv->fat);
+ ret = f_mount(&priv->fat);
+ if (ret)
+ goto err_mount;
return 0;
+
+err_mount:
+ cdev_close(priv->cdev);
+err_open:
+ free(priv);
+
+ return ret;
}
static void fat_remove(struct device_d *dev)
diff --git a/fs/fat/ff.c b/fs/fat/ff.c
index a720389424..2d476ee2d5 100644
--- a/fs/fat/ff.c
+++ b/fs/fat/ff.c
@@ -1699,9 +1699,7 @@ int f_mount (
{
fs->fs_type = 0; /* Clear new fs object */
- chk_mounted(fs, 0);
-
- return 0;
+ return chk_mounted(fs, 0);
}
/*