[PATCH] udf: avoid uninitialized variable use

From: Arnd Bergmann
Date: Fri Jan 01 2016 - 09:21:54 EST


A new warning has come up from a recent cleanup:

fs/udf/inode.c: In function 'udf_setup_indirect_aext':
fs/udf/inode.c:1927:28: warning: 'adsize' may be used uninitialized in this function [-Wmaybe-uninitialized]

If the alloc_type is neither ICBTAG_FLAG_AD_SHORT nor
ICBTAG_FLAG_AD_LONG, the value of adsize is undefined. Currently,
callers of these functions make sure alloc_type is one of the two valid
ones but for future proofing make sure we handle the case of invalid
alloc type as well. This changes the code to return -EIOin that case.

Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
Fixes: fcea62babc81 ("udf: Factor out code for creating indirect extent")
Signed-off-by: Jan Kara <jack@xxxxxxx>
---
fs/udf/inode.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 846294891925..91d8fa9d87a4 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -1889,6 +1889,8 @@ int udf_setup_indirect_aext(struct inode *inode, int block,
adsize = sizeof(struct short_ad);
else if (UDF_I(inode)->i_alloc_type == ICBTAG_FLAG_AD_LONG)
adsize = sizeof(struct long_ad);
+ else
+ return -EIO;

neloc.logicalBlockNum = block;
neloc.partitionReferenceNum = epos->block.partitionReferenceNum;
@@ -1962,6 +1964,8 @@ int __udf_add_aext(struct inode *inode, struct extent_position *epos,
adsize = sizeof(struct short_ad);
else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG)
adsize = sizeof(struct long_ad);
+ else
+ return -EIO;

if (!epos->bh) {
WARN_ON(iinfo->i_lenAlloc !=
--
2.6.2


--9jxsPFA5p3P2qPhR--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/