[PATCH] adfs: obj.file_id is uninitialized if __adfs_dir_get() returns error code
From: Yizhuo
Date: Thu Aug 29 2019 - 01:35:04 EST
Inside function adfs_dir_find_entry(), obj.file_id could be uninitialized
if __adfs_dir_get() returns error code. However, the return check cannot
promise the initialization of obj.file_id, which is used in the if
statement. This is potentially unsafe.
Signed-off-by: Yizhuo <yzhai003@xxxxxxx>
---
fs/adfs/dir_f.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/adfs/dir_f.c b/fs/adfs/dir_f.c
index 0fbfd0b04ae0..d7fc47598e78 100644
--- a/fs/adfs/dir_f.c
+++ b/fs/adfs/dir_f.c
@@ -335,7 +335,7 @@ adfs_dir_find_entry(struct adfs_dir *dir, unsigned long object_id)
ret = -ENOENT;
for (pos = 5; pos < ADFS_NUM_DIR_ENTRIES * 26 + 5; pos += 26) {
- struct object_info obj;
+ struct object_info obj = {};
if (!__adfs_dir_get(dir, pos, &obj))
break;
--
2.17.1