[PATCH] btrfs: Check if tgt_device is not null

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



btrfs_err_in_rcu indiscriminately dereferences tgt_device to access its
->name member in an error path. However, couple of lines below there is code
which checks whether tgt_device is not NULL. Let's be consistent and check if
the tgt_device is NULL before dereferencing it.

Signed-off-by: Nikolay Borisov <nborisov@xxxxxxxx>
---
 fs/btrfs/dev-replace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index bee3edeea7a3..e2a16cb8f7f3 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -541,7 +541,8 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
 				 src_device->missing ? "<missing disk>" :
 				 rcu_str_deref(src_device->name),
 				 src_device->devid,
-				 rcu_str_deref(tgt_device->name), scrub_ret);
+				 tgt_device ? rcu_str_deref(tgt_device->name) :
+				 "<missing disk>", scrub_ret);
 		btrfs_dev_replace_unlock(dev_replace, 1);
 		mutex_unlock(&fs_info->chunk_mutex);
 		mutex_unlock(&fs_info->fs_devices->device_list_mutex);
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux