diff options
| author | Joseph Qi <joseph.qi@huawei.com> | 2015-04-14 18:43:33 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-14 19:48:58 -0400 |
| commit | 023d4ea358494ccfeb37abfe5b0fd01b45a6051c (patch) | |
| tree | 236d2f72d3a72bc60f1cfce95c3448ad194951e2 | |
| parent | 7c01ad8fe7c159d7e1ddbd8e586d4d0dfed7ab3d (diff) | |
ocfs2: fix possible uninitialized variable access
In ocfs2_local_alloc_find_clear_bits and ocfs2_get_dentry, variable
numfound and set may be uninitialized and then used in tracepoint. In
ocfs2_xattr_block_get and ocfs2_delete_xattr_in_bucket, variable block_off
and xv may be uninitialized and then used in the following logic due to
unchecked return value.
This patch fixes these possible issues.
Signed-off-by: Joseph Qi <joseph.qi@huawei.com>
Cc: Mark Fasheh <mfasheh@suse.com>
Cc: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
| -rw-r--r-- | fs/ocfs2/export.c | 2 | ||||
| -rw-r--r-- | fs/ocfs2/localalloc.c | 2 | ||||
| -rw-r--r-- | fs/ocfs2/xattr.c | 8 |
3 files changed, 10 insertions, 2 deletions
diff --git a/fs/ocfs2/export.c b/fs/ocfs2/export.c index 29651167190d..540dc4bdd042 100644 --- a/fs/ocfs2/export.c +++ b/fs/ocfs2/export.c | |||
| @@ -82,7 +82,6 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb, | |||
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | status = ocfs2_test_inode_bit(osb, blkno, &set); | 84 | status = ocfs2_test_inode_bit(osb, blkno, &set); |
| 85 | trace_ocfs2_get_dentry_test_bit(status, set); | ||
| 86 | if (status < 0) { | 85 | if (status < 0) { |
| 87 | if (status == -EINVAL) { | 86 | if (status == -EINVAL) { |
| 88 | /* | 87 | /* |
| @@ -96,6 +95,7 @@ static struct dentry *ocfs2_get_dentry(struct super_block *sb, | |||
| 96 | goto unlock_nfs_sync; | 95 | goto unlock_nfs_sync; |
| 97 | } | 96 | } |
| 98 | 97 | ||
| 98 | trace_ocfs2_get_dentry_test_bit(status, set); | ||
| 99 | /* If the inode allocator bit is clear, this inode must be stale */ | 99 | /* If the inode allocator bit is clear, this inode must be stale */ |
| 100 | if (!set) { | 100 | if (!set) { |
| 101 | status = -ESTALE; | 101 | status = -ESTALE; |
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index 096cff6f9ba8..857bbbcd39f3 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c | |||
| @@ -839,7 +839,7 @@ static int ocfs2_local_alloc_find_clear_bits(struct ocfs2_super *osb, | |||
| 839 | u32 *numbits, | 839 | u32 *numbits, |
| 840 | struct ocfs2_alloc_reservation *resv) | 840 | struct ocfs2_alloc_reservation *resv) |
| 841 | { | 841 | { |
| 842 | int numfound, bitoff, left, startoff, lastzero; | 842 | int numfound = 0, bitoff, left, startoff, lastzero; |
| 843 | int local_resv = 0; | 843 | int local_resv = 0; |
| 844 | struct ocfs2_alloc_reservation r; | 844 | struct ocfs2_alloc_reservation r; |
| 845 | void *bitmap = NULL; | 845 | void *bitmap = NULL; |
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c index 85b190dc132f..4ca7533be479 100644 --- a/fs/ocfs2/xattr.c +++ b/fs/ocfs2/xattr.c | |||
| @@ -1238,6 +1238,10 @@ static int ocfs2_xattr_block_get(struct inode *inode, | |||
| 1238 | i, | 1238 | i, |
| 1239 | &block_off, | 1239 | &block_off, |
| 1240 | &name_offset); | 1240 | &name_offset); |
| 1241 | if (ret) { | ||
| 1242 | mlog_errno(ret); | ||
| 1243 | goto cleanup; | ||
| 1244 | } | ||
| 1241 | xs->base = bucket_block(xs->bucket, block_off); | 1245 | xs->base = bucket_block(xs->bucket, block_off); |
| 1242 | } | 1246 | } |
| 1243 | if (ocfs2_xattr_is_local(xs->here)) { | 1247 | if (ocfs2_xattr_is_local(xs->here)) { |
| @@ -5665,6 +5669,10 @@ static int ocfs2_delete_xattr_in_bucket(struct inode *inode, | |||
| 5665 | 5669 | ||
| 5666 | ret = ocfs2_get_xattr_tree_value_root(inode->i_sb, bucket, | 5670 | ret = ocfs2_get_xattr_tree_value_root(inode->i_sb, bucket, |
| 5667 | i, &xv, NULL); | 5671 | i, &xv, NULL); |
| 5672 | if (ret) { | ||
| 5673 | mlog_errno(ret); | ||
| 5674 | break; | ||
| 5675 | } | ||
| 5668 | 5676 | ||
| 5669 | ret = ocfs2_lock_xattr_remove_allocators(inode, xv, | 5677 | ret = ocfs2_lock_xattr_remove_allocators(inode, xv, |
| 5670 | args->ref_ci, | 5678 | args->ref_ci, |
