summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorCarsten Schlote <c.schlote@konzeptpark.de>2008-02-15 20:26:45 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2008-02-19 09:28:17 +0100
commitc1bba7e22696d4af1446c0d38675d077075953da (patch)
tree2b73d28653954589e550a3826ce9cadbdd3ab320 /fs
parent7f266db94966746cc07774b3c9b53c7368d7f15b (diff)
downloadbarebox-c1bba7e22696d4af1446c0d38675d077075953da.tar.gz
barebox-c1bba7e22696d4af1446c0d38675d077075953da.tar.xz
[general] Fixed crash in fs.h, when called with fsdrv.create == NULL
When a nor0 devices has no partitions assigned, then a call to open() to create a file will jump with a NULL fct ptr. Much more cheching code is missing and pointers to function are jumped without any NULL ptr check. This must be fixed as well later. Signed-off-by: Carsten Schlote <c.schlote@konzeptpark.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/fs.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/fs.c b/fs/fs.c
index 8d39232818..6be2eba396 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -406,8 +406,11 @@ int open(const char *pathname, int flags, ...)
}
if (!exist) {
- errno = fsdrv->create(dev, path,
- S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO);
+ if (NULL != fsdrv->create)
+ errno = fsdrv->create(dev, path,
+ S_IFREG | S_IRWXU | S_IRWXG | S_IRWXO);
+ else
+ errno = -EROFS;
if (errno)
goto out;
}