Skip to contentSkip to conversation

Btrfs: get/set for struct header fields

DISCUSSION Dan Carpenter 1 participant 1 message Mar 18, 2016 Btrfs file system

lore
Share & tools
lore
#0 lore raw

Hello Chris Mason,

The patch 7518a238ea01: "Btrfs: get/set for struct header fields" from Mar 12, 2007, leads to the following static checker warning:

	fs/btrfs/print-tree.c:359 btrfs_print_tree()
	error: 'next' dereferencing possible ERR_PTR()

fs/btrfs/print-tree.c
355 for (i = 0; i < nr; i++) {
356 struct extent_buffer *next = read_tree_block(root,

                                                     ^^^^^^^^^^^^^^^

This function can fail. The original code was buggy as well before 7518a238ea01.

   357                                          btrfs_node_blockptr(c, i),
   358                                          btrfs_node_ptr_generation(c, i));
   359                  if (btrfs_is_leaf(next) &&
   360                     level != 1)
   361                          BUG();
   362                  if (btrfs_header_level(next) !=
   363                         level - 1)
   364                          BUG();
   365                  btrfs_print_tree(root, next);
   366                  free_extent_buffer(next);
   367          }

regards,
dan carpenter