All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: Fix uninitialized ret in btrfsic_process_superblock_dev_mirror
@ 2020-02-24 12:56 Nikolay Borisov
  2020-02-24 12:57 ` Nikolay Borisov
  2020-02-24 13:00 ` Qu Wenruo
  0 siblings, 2 replies; 4+ messages in thread
From: Nikolay Borisov @ 2020-02-24 12:56 UTC (permalink / raw)
  To: linux-btrfs; +Cc: 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.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 fs/btrfs/check-integrity.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 23dd65e1c5e3..85b27e9742c8 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: Fix uninitialized ret in btrfsic_process_superblock_dev_mirror
  2020-02-24 12:56 [PATCH] btrfs: Fix uninitialized ret in btrfsic_process_superblock_dev_mirror Nikolay Borisov
@ 2020-02-24 12:57 ` Nikolay Borisov
  2020-02-24 15:16   ` David Sterba
  2020-02-24 13:00 ` Qu Wenruo
  1 sibling, 1 reply; 4+ messages in thread
From: Nikolay Borisov @ 2020-02-24 12:57 UTC (permalink / raw)
  To: linux-btrfs



On 24.02.20 г. 14:56 ч., Nikolay Borisov wrote:
> 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.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>

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

> ---
>  fs/btrfs/check-integrity.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
> index 23dd65e1c5e3..85b27e9742c8 100644
> --- a/fs/btrfs/check-integrity.c
> +++ b/fs/btrfs/check-integrity.c
> @@ -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
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: Fix uninitialized ret in btrfsic_process_superblock_dev_mirror
  2020-02-24 12:56 [PATCH] btrfs: Fix uninitialized ret in btrfsic_process_superblock_dev_mirror Nikolay Borisov
  2020-02-24 12:57 ` Nikolay Borisov
@ 2020-02-24 13:00 ` Qu Wenruo
  1 sibling, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2020-02-24 13:00 UTC (permalink / raw)
  To: Nikolay Borisov, linux-btrfs



On 2020/2/24 下午8:56, Nikolay Borisov wrote:
> 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.
>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
>  fs/btrfs/check-integrity.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
> index 23dd65e1c5e3..85b27e9742c8 100644
> --- a/fs/btrfs/check-integrity.c
> +++ b/fs/btrfs/check-integrity.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: Fix uninitialized ret in btrfsic_process_superblock_dev_mirror
  2020-02-24 12:57 ` Nikolay Borisov
@ 2020-02-24 15:16   ` David Sterba
  0 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2020-02-24 15:16 UTC (permalink / raw)
  To: Nikolay Borisov; +Cc: linux-btrfs

On Mon, Feb 24, 2020 at 02:57:00PM +0200, Nikolay Borisov wrote:
> 
> 
> On 24.02.20 г. 14:56 ч., Nikolay Borisov wrote:
> > 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.
> > 
> > Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> 
> This ideally has to be folded in:
> 5a03d907a555 ("btrfs: remove buffer_heads form super block mirror
> integrity checking")

Folded and pushed, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-02-24 15:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-24 12:56 [PATCH] btrfs: Fix uninitialized ret in btrfsic_process_superblock_dev_mirror Nikolay Borisov
2020-02-24 12:57 ` Nikolay Borisov
2020-02-24 15:16   ` David Sterba
2020-02-24 13:00 ` Qu Wenruo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.