diff options
author | Josef Bacik <jbacik@fusionio.com> | 2012-08-02 18:23:59 +0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2012-08-29 00:53:29 +0400 |
commit | 99f5944b8477914406173b47b4f261356286730b (patch) | |
tree | a2b3037ad77b3841467d9e7ff4b0dde3ea2eb380 /fs | |
parent | aa9ddcd4b5557102fa25695c11904f249b4dec49 (diff) | |
download | linux-99f5944b8477914406173b47b4f261356286730b.tar.xz |
Btrfs: do not strdup non existent strings
When we close devices we add back empty devices for some reason that escapes
me. In the case of a missing dev we don't allocate an rcu_string for it's
name, so check to see if the device has a name and if it doesn't don't
bother strdup()'ing it. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/volumes.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index b8708f994e67..3b394503bd4e 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -569,9 +569,11 @@ static int __btrfs_close_devices(struct btrfs_fs_devices *fs_devices) memcpy(new_device, device, sizeof(*new_device)); /* Safe because we are under uuid_mutex */ - name = rcu_string_strdup(device->name->str, GFP_NOFS); - BUG_ON(device->name && !name); /* -ENOMEM */ - rcu_assign_pointer(new_device->name, name); + if (device->name) { + name = rcu_string_strdup(device->name->str, GFP_NOFS); + BUG_ON(device->name && !name); /* -ENOMEM */ + rcu_assign_pointer(new_device->name, name); + } new_device->bdev = NULL; new_device->writeable = 0; new_device->in_fs_metadata = 0; |