mac80211: fix unaligned access in mesh table hash function
authorFelix Fietkau <nbd@nbd.name>
Wed, 13 Mar 2019 17:54:27 +0000 (18:54 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 29 Mar 2019 10:18:48 +0000 (11:18 +0100)
The pointer to the last four bytes of the address is not guaranteed to be
aligned, so we need to use __get_unaligned_cpu32 here

Signed-off-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/mac80211/mesh_pathtbl.c

index 95eb506..b76a2ae 100644 (file)
@@ -23,7 +23,7 @@ static void mesh_path_free_rcu(struct mesh_table *tbl, struct mesh_path *mpath);
 static u32 mesh_table_hash(const void *addr, u32 len, u32 seed)
 {
        /* Use last four bytes of hw addr as hash index */
-       return jhash_1word(*(u32 *)(addr+2), seed);
+       return jhash_1word(__get_unaligned_cpu32((u8 *)addr + 2), seed);
 }
 
 static const struct rhashtable_params mesh_rht_params = {