projects
/
yaffs2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
yaffsfs.c: Fix NULL dereference in yaffs_unmount2_reldev()
[yaffs2.git]
/
direct
/
yaffsfs.c
diff --git
a/direct/yaffsfs.c
b/direct/yaffsfs.c
index af8c82bf03e5466b0815aa8b987d1e1a2f381d5e..823f7edcfc21c9dd7e2247e1da8781e8a74eb7e1 100644
(file)
--- a/
direct/yaffsfs.c
+++ b/
direct/yaffsfs.c
@@
-1943,17
+1943,21
@@
static int yaffsfs_DoUtime(struct yaffs_obj *obj,
}
#if !CONFIG_YAFFS_WINCE
}
#if !CONFIG_YAFFS_WINCE
+ // if the the buffer is null then create one with the fields set to the current time.
if (!buf) {
local.actime = Y_CURRENT_TIME;
local.modtime = local.actime;
buf = &local;
}
if (!buf) {
local.actime = Y_CURRENT_TIME;
local.modtime = local.actime;
buf = &local;
}
+ // copy the buffer's time into the obj.
if (obj) {
int result;
obj->yst_atime = buf->actime;
obj->yst_mtime = buf->modtime;
if (obj) {
int result;
obj->yst_atime = buf->actime;
obj->yst_mtime = buf->modtime;
+
+ // set the obj to dirty to cause it to be written to flash during the next flush operation.
obj->dirty = 1;
result = yaffs_flush_file(obj, 0, 0, 0);
retVal = result == YAFFS_OK ? 0 : -1;
obj->dirty = 1;
result = yaffs_flush_file(obj, 0, 0, 0);
retVal = result == YAFFS_OK ? 0 : -1;
@@
-3050,6
+3054,7
@@
int yaffs_remount_common(struct yaffs_dev *dev, const YCHAR *path,
int force, int read_only)
{
int retVal = -1;
int force, int read_only)
{
int retVal = -1;
+ int was_read_only;
if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
yaffsfs_SetError(-EFAULT);
@@
-3072,7
+3077,11
@@
int yaffs_remount_common(struct yaffs_dev *dev, const YCHAR *path,
if (force || !yaffsfs_IsDevBusy(dev)) {
if (read_only)
yaffs_checkpoint_save(dev);
if (force || !yaffsfs_IsDevBusy(dev)) {
if (read_only)
yaffs_checkpoint_save(dev);
+ was_read_only = dev->read_only;
dev->read_only = read_only ? 1 : 0;
dev->read_only = read_only ? 1 : 0;
+ if (was_read_only && !read_only) {
+ yaffs_guts_cleanup(dev);
+ }
retVal = 0;
} else
yaffsfs_SetError(-EBUSY);
retVal = 0;
} else
yaffsfs_SetError(-EBUSY);
@@
-3101,14
+3110,17
@@
int yaffs_unmount2_common(struct yaffs_dev *dev, const YCHAR *path, int force)
{
int retVal = -1;
{
int retVal = -1;
- if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
- yaffsfs_SetError(-EFAULT);
- return -1;
- }
- if (yaffsfs_CheckPath(path) < 0) {
- yaffsfs_SetError(-ENAMETOOLONG);
- return -1;
+ if (!dev) {
+ if (yaffsfs_CheckMemRegion(path, 0, 0) < 0) {
+ yaffsfs_SetError(-EFAULT);
+ return -1;
+ }
+
+ if (yaffsfs_CheckPath(path) < 0) {
+ yaffsfs_SetError(-ENAMETOOLONG);
+ return -1;
+ }
}
yaffsfs_Lock();
}
yaffsfs_Lock();