Skip to contentSkip to conversation

Btrfs: fix up read_tree_block to return proper error

DISCUSSION Dan Carpenter 2 participants 2 messages Mar 18, 2016 – Mar 21, 2016 Btrfs file system

lore
Share & tools
lore
#0 lore raw

Hello Liu Bo,

The patch 64c043de466d: "Btrfs: fix up read_tree_block to return proper error" from May 25, 2015, leads to the following static checker warning:

	fs/btrfs/relocation.c:1858 replace_path()
	error: 'eb' dereferencing possible ERR_PTR()

fs/btrfs/relocation.c
1850 eb = read_tree_block(dest, old_bytenr, old_ptr_gen);

  1851                          if (IS_ERR(eb)) {
                                    ^^^^^^^^^^
  1852                                  ret = PTR_ERR(eb);

Missing break or continue?

1853 } else if (!extent_buffer_uptodate(eb)) {

  1854                                  ret = -EIO;
  1855                                  free_extent_buffer(eb);
  1856                                  break;
  1857                          }
  1858                          btrfs_tree_lock(eb);
                                                ^^

Dereference.

1859 if (cow) {
1860 ret = btrfs_cow_block(trans, dest, eb, parent,
1861 slot, &eb);

regards,
dan carpenter

#1 lore raw

Hi Dan,

Quoted 25 lines · Dan Carpenter

Hello Liu Bo,

The patch 64c043de466d: "Btrfs: fix up read_tree_block to return proper error" from May 25, 2015, leads to the following static checker warning:

	fs/btrfs/relocation.c:1858 replace_path()
	error: 'eb' dereferencing possible ERR_PTR()

fs/btrfs/relocation.c
1850 eb = read_tree_block(dest, old_bytenr, old_ptr_gen);

  1851                          if (IS_ERR(eb)) {
                                    ^^^^^^^^^^
  1852                                  ret = PTR_ERR(eb);

Missing break or continue?

1853 } else if (!extent_buffer_uptodate(eb)) {

  1854                                  ret = -EIO;
  1855                                  free_extent_buffer(eb);
  1856                                  break;
  1857                          }
  1858                          btrfs_tree_lock(eb);
                                                ^^
Quoted 5 lines

Dereference.

1859 if (cow) {
1860 ret = btrfs_cow_block(trans, dest, eb, parent,
1861 slot, &eb);

Ah, thanks a lot for reporting this!

I've double checked other places in that patch, the above one is the only place we have such a problem.

I'll cook a patch to fix it.

Thanks,

-liubo