summaryrefslogtreecommitdiff
path: root/dir-item.c
diff options
context:
space:
mode:
authorDavid Miller <davem@davemloft.net>2008-02-15 11:19:58 -0500
committerDavid Woodhouse <dwmw2@hera.kernel.org>2008-02-15 11:19:58 -0500
commit8871a0eaa98d951727e97c615d831af9a60432ae (patch)
tree7701fa42a830e2fba095199bfe25c62b42b9d36e /dir-item.c
parent0c6513b1d120ba99a3d5f3641cb059723245ec00 (diff)
Unaligned access fixes
The first problem is that these SETGET macros lose typing information, and therefore can't see the 'packed' attribute and therefore take unaligned access SIGBUS signals on sparc64 when trying to derefernce the member. The next problem is a similar issue in btrfs_name_hash(). This gets passed things like &key.offset which is a member of a packed structure, losing this packed'ness information btrfs_name_hash() performs a potentially unaligned memory access, again resulting in a SIGBUS.
Diffstat (limited to 'dir-item.c')
-rw-r--r--dir-item.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/dir-item.c b/dir-item.c
index 98628db2..aaaad6a6 100644
--- a/dir-item.c
+++ b/dir-item.c
@@ -71,8 +71,7 @@ int btrfs_insert_xattr_item(struct btrfs_trans_handle *trans,
key.objectid = dir;
btrfs_set_key_type(&key, BTRFS_XATTR_ITEM_KEY);
- ret = btrfs_name_hash(name, name_len, &key.offset);
- BUG_ON(ret);
+ key.offset = btrfs_name_hash(name, name_len);
path = btrfs_alloc_path();
if (!path)
return -ENOMEM;
@@ -122,8 +121,7 @@ int btrfs_insert_dir_item(struct btrfs_trans_handle *trans, struct btrfs_root
key.objectid = dir;
btrfs_set_key_type(&key, BTRFS_DIR_ITEM_KEY);
- ret = btrfs_name_hash(name, name_len, &key.offset);
- BUG_ON(ret);
+ key.offset = btrfs_name_hash(name, name_len);
path = btrfs_alloc_path();
data_size = sizeof(*dir_item) + name_len;
dir_item = insert_with_overflow(trans, root, path, &key, data_size,
@@ -196,8 +194,7 @@ struct btrfs_dir_item *btrfs_lookup_dir_item(struct btrfs_trans_handle *trans,
key.objectid = dir;
btrfs_set_key_type(&key, BTRFS_DIR_ITEM_KEY);
- ret = btrfs_name_hash(name, name_len, &key.offset);
- BUG_ON(ret);
+ key.offset = btrfs_name_hash(name, name_len);
ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow);
if (ret < 0)
@@ -258,8 +255,7 @@ struct btrfs_dir_item *btrfs_lookup_xattr(struct btrfs_trans_handle *trans,
key.objectid = dir;
btrfs_set_key_type(&key, BTRFS_XATTR_ITEM_KEY);
- ret = btrfs_name_hash(name, name_len, &key.offset);
- BUG_ON(ret);
+ key.offset = btrfs_name_hash(name, name_len);
ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow);
if (ret < 0)
return ERR_PTR(ret);