Skip to contentSkip to conversation

btrfs: Fix uninitialized ret in btrfsic_process_superblock_dev_mirror

PATCH In review Nikolay Borisov 3 participants 4 messages Feb 24, 2020 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: Fix uninitialized ret in btrfsic_process_superblock_dev_mirror

We could return ret uninitlaized in case of success. Before the code was returning 0 explicitly in case of success but now it will be a random value from the stack. That's due to ret being set only in error conditions.

---
 fs/btrfs/check-integrity.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/check-integrity.c +1 -1
index 23dd65e1c5e3..85b27e9742c8 100644
@@ -766,7 +766,7 @@ static int btrfsic_process_superblock_dev_mirror(
 	struct block_device *const superblock_bdev = device->bdev;
 	struct page *page;
 	struct address_space *mapping = superblock_bdev->bd_inode->i_mapping;
-	int ret;
+	int ret = 0;
 
 	/* super block bytenr is always the unmapped device bytenr */
 	dev_bytenr = btrfs_sb_offset(superblock_mirror_num);

--
2.17.1

#1 lore raw
Quoted 5 lines · Nikolay Borisov

We could return ret uninitlaized in case of success. Before the code was returning 0 explicitly in case of success but now it will be a random value from the stack. That's due to ret being set only in error conditions.

This ideally has to be folded in:
5a03d907a555 ("btrfs: remove buffer_heads form super block mirror integrity checking")

Quoted 20 lines
---
 fs/btrfs/check-integrity.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/check-integrity.c +1 -2
index 23dd65e1c5e3..85b27e9742c8 100644
@@ -766,7 +766,7 @@ static int btrfsic_process_superblock_dev_mirror(
 	struct block_device *const superblock_bdev = device->bdev;
 	struct page *page;
 	struct address_space *mapping = superblock_bdev->bd_inode->i_mapping;
-	int ret;
+	int ret = 0;
 
 	/* super block bytenr is always the unmapped device bytenr */
 	dev_bytenr = btrfs_sb_offset(superblock_mirror_num);
--

2.17.1

#2 lore raw
Quoted 7 lines · Nikolay Borisov
Quoted 4 lines · Nikolay Borisov

We could return ret uninitlaized in case of success. Before the code was returning 0 explicitly in case of success but now it will be a random value from the stack. That's due to ret being set only in error conditions.

Quoted 5 lines
Quoted 1 line

This ideally has to be folded in:
5a03d907a555 ("btrfs: remove buffer_heads form super block mirror integrity checking")

Folded and pushed, thanks.

Reviewed-by on v1 1/1
#3 lore raw
In reply to Nikolay Borisov
Quoted 5 lines · Nikolay Borisov

We could return ret uninitlaized in case of success. Before the code was returning 0 explicitly in case of success but now it will be a random value from the stack. That's due to ret being set only in error conditions.

Thanks,
Qu

Quoted 20 lines
---
 fs/btrfs/check-integrity.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/check-integrity.c +1 -2
index 23dd65e1c5e3..85b27e9742c8 100644
@@ -766,7 +766,7 @@ static int btrfsic_process_superblock_dev_mirror(
 	struct block_device *const superblock_bdev = device->bdev;
 	struct page *page;
 	struct address_space *mapping = superblock_bdev->bd_inode->i_mapping;
-	int ret;
+	int ret = 0;
 
 	/* super block bytenr is always the unmapped device bytenr */
 	dev_bytenr = btrfs_sb_offset(superblock_mirror_num);
--

2.17.1