Bug 188741 - Function btrfs_uuid_scan_kthread() does not return error code on failures
Summary: Function btrfs_uuid_scan_kthread() does not return error code on failures
Status: NEW
Alias: None
Product: File System
Classification: Unclassified
Component: btrfs (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Josef Bacik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-11-25 10:53 UTC by bianpan
Modified: 2016-11-25 10:53 UTC (History)
0 users

See Also:
Kernel Version: linux-4.9-rc6
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description bianpan 2016-11-25 10:53:20 UTC
Function btrfs_uuid_scan_kthread() is defined in file fs/btrfs/volumes.c. When the call to btrfs_alloc_path() fails, it assigns "-ENOMEM" to variable ret and jumps to label "out". However, 0 rather than ret is returned at the end. As a result, the callers will not be able to detect errors during the execution of btrfs_uuid_scan_kthread(). Maybe it is better to use "return ret;" instead of "return 0;" at line 356. Codes related to this bug are summarised as follows.

4094 static int btrfs_uuid_scan_kthread(void *data)
4095 {
4096     struct btrfs_fs_info *fs_info = data;
4097     struct btrfs_root *root = fs_info->tree_root;
4098     struct btrfs_key key;
4099     struct btrfs_key max_key;
4100     struct btrfs_path *path = NULL;
4101     int ret = 0;
4102     struct extent_buffer *eb;
4103     int slot;
4104     struct btrfs_root_item root_item;
4105     u32 item_size;
4106     struct btrfs_trans_handle *trans = NULL;
4107 
4108     path = btrfs_alloc_path();
4109     if (!path) {
4110         ret = -ENOMEM;
4111         goto out;
4112     }
         ...
4216 out:
4217     btrfs_free_path(path);
4218     if (trans && !IS_ERR(trans))
4219         btrfs_end_transaction(trans, fs_info->uuid_root);
4220     if (ret)
4221         btrfs_warn(fs_info, "btrfs_uuid_scan_kthread failed %d", ret);
4222     else
4223         set_bit(BTRFS_FS_UPDATE_UUID_TREE_GEN, &fs_info->flags);
4224     up(&fs_info->uuid_tree_rescan_sem);
4225     return 0;       // return ret?
4226 }

Thanks very much!

Note You need to log in before you can comment on or make changes to this bug.