From: Felix Fietkau Date: Wed, 23 Jan 2013 01:41:16 +0000 (+0100) Subject: blob/blobmsg: use 32 bit load/store for 64 bit access, unaligned attributes cause... X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=8a89e7f388f708243e5596911c2e17ebf29d80ab;p=oweals%2Flibubox.git blob/blobmsg: use 32 bit load/store for 64 bit access, unaligned attributes cause data corruption on ARM Signed-off-by: Felix Fietkau --- diff --git a/blob.h b/blob.h index a8ddce9..557899d 100644 --- a/blob.h +++ b/blob.h @@ -191,8 +191,10 @@ blob_get_u32(const struct blob_attr *attr) static inline uint64_t blob_get_u64(const struct blob_attr *attr) { - uint64_t *tmp = (uint64_t*)attr->data; - return be64_to_cpu(*tmp); + uint32_t *ptr = blob_data(attr); + uint64_t tmp = ((uint64_t) be32_to_cpu(ptr[0])) << 32; + tmp |= be32_to_cpu(ptr[1]); + return tmp; } static inline int8_t diff --git a/blobmsg.h b/blobmsg.h index 44f1f3b..9fdf486 100644 --- a/blobmsg.h +++ b/blobmsg.h @@ -180,7 +180,10 @@ static inline uint32_t blobmsg_get_u32(struct blob_attr *attr) static inline uint64_t blobmsg_get_u64(struct blob_attr *attr) { - return be64_to_cpu(*(uint64_t *) blobmsg_data(attr)); + uint32_t *ptr = blobmsg_data(attr); + uint64_t tmp = ((uint64_t) be32_to_cpu(ptr[0])) << 32; + tmp |= be32_to_cpu(ptr[1]); + return tmp; } static inline char *blobmsg_get_string(struct blob_attr *attr)