btrfs-progs: fix unaligned u64 access in btrfs_alloc_data_chunk
authorDavid Sterba <dsterba@suse.com>
Fri, 4 Nov 2016 14:11:54 +0000 (15:11 +0100)
committerDavid Sterba <dsterba@suse.com>
Wed, 9 Nov 2016 12:47:34 +0000 (13:47 +0100)
The key.offset member is not well-aligned as the key is packed, use a
temporary variable to pass the argument. Reported by ASAN in misc test
002.

Signed-off-by: David Sterba <dsterba@suse.com>
volumes.c

index 70d8940..c128472 100644 (file)
--- a/volumes.c
+++ b/volumes.c
@@ -1080,9 +1080,12 @@ int btrfs_alloc_data_chunk(struct btrfs_trans_handle *trans,
                key.offset = *start;
                dev_offset = *start;
        } else {
+               u64 tmp;
+
                ret = find_next_chunk(chunk_root,
                                      BTRFS_FIRST_CHUNK_TREE_OBJECTID,
-                                     &key.offset);
+                                     &tmp);
+               key.offset = tmp;
                if (ret)
                        return ret;
        }