summaryrefslogtreecommitdiff
path: root/yaffs_vfs_multi.c
diff options
context:
space:
mode:
authorCharles Manning <cdhmanning@gmail.com>2011-01-10 11:58:11 +1300
committerCharles Manning <cdhmanning@gmail.com>2011-01-10 11:58:11 +1300
commitb70ea39d4f2547564197afa8866b388301765583 (patch)
tree62a492ec65627c05a11c71f869bb8693fed8ca76 /yaffs_vfs_multi.c
parenta8e8fa708152c823e534b7b004bfbd121dd1670e (diff)
yaffs: Sort out issues raised by Coverity
Coverity checks raised some issues, particularly with NULL checks. Fix them. Signed-off-by: Charles Manning <cdhmanning@gmail.com>
Diffstat (limited to 'yaffs_vfs_multi.c')
-rw-r--r--yaffs_vfs_multi.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/yaffs_vfs_multi.c b/yaffs_vfs_multi.c
index 9feecdf..78e2f9f 100644
--- a/yaffs_vfs_multi.c
+++ b/yaffs_vfs_multi.c
@@ -692,11 +692,9 @@ static void yaffs_remove_obj_callback(struct yaffs_obj *obj)
* the search context to the next object to prevent a hanging pointer.
*/
list_for_each(i, search_contexts) {
- if (i) {
- sc = list_entry(i, struct yaffs_search_context, others);
- if (sc->next_return == obj)
- yaffs_search_advance(sc);
- }
+ sc = list_entry(i, struct yaffs_search_context, others);
+ if (sc->next_return == obj)
+ yaffs_search_advance(sc);
}
}
@@ -1421,6 +1419,12 @@ static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
obj = yaffs_dentry_to_obj(f->f_dentry);
+ if (!obj) {
+ yaffs_trace(YAFFS_TRACE_OS,
+ "yaffs_file_write: hey obj is null!");
+ return -EINVAL;
+ }
+
dev = obj->my_dev;
yaffs_gross_lock(dev);
@@ -1432,13 +1436,9 @@ static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
else
ipos = *pos;
- if (!obj)
- yaffs_trace(YAFFS_TRACE_OS,
- "yaffs_file_write: hey obj is null!");
- else
- yaffs_trace(YAFFS_TRACE_OS,
- "yaffs_file_write about to write writing %u(%x) bytes to object %d at %d(%x)",
- (unsigned)n, (unsigned)n, obj->obj_id, ipos, ipos);
+ yaffs_trace(YAFFS_TRACE_OS,
+ "yaffs_file_write about to write writing %u(%x) bytes to object %d at %d(%x)",
+ (unsigned)n, (unsigned)n, obj->obj_id, ipos, ipos);
n_written = yaffs_wr_file(obj, buf, ipos, n, 0);
@@ -2623,6 +2623,11 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,
struct yaffs_linux_context *context_iterator;
struct list_head *l;
+ if (!sb) {
+ printk(KERN_INFO "yaffs: sb is NULL\n");
+ return NULL;
+ }
+
sb->s_magic = YAFFS_MAGIC;
sb->s_op = &yaffs_super_ops;
sb->s_flags |= MS_NOATIME;
@@ -2633,9 +2638,7 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,
sb->s_export_op = &yaffs_export_ops;
#endif
- if (!sb)
- printk(KERN_INFO "yaffs: sb is NULL\n");
- else if (!sb->s_dev)
+ if (!sb->s_dev)
printk(KERN_INFO "yaffs: sb->s_dev is NULL\n");
else if (!yaffs_devname(sb, devname_buf))
printk(KERN_INFO "yaffs: devname is NULL\n");