hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I8LKYV
--------------------------------
Variable swp_type_slots is an array with type 'struct swap_slots_cache[]'. So raw_cpu_ptr(&swp_type_slots) is correspoinding pointer of array. Its type is 'struct swap_slots_cache[]' rather than 'struct swap_slots_cache'. So the offset of raw_cpu_ptr(&swp_type_slots)[swap_type] is out-of-bounds. Use raw_cpu_ptr(&swp_type_slots[swap_type]) to get the correct variable.
Fixes: 8e41c366cd1f ("mm: swap_slots: add per-type slot cache") Signed-off-by: Liu Shixin liushixin2@huawei.com --- mm/swap_slots.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/swap_slots.c b/mm/swap_slots.c index b7958ca276c2..930f48358254 100644 --- a/mm/swap_slots.c +++ b/mm/swap_slots.c @@ -122,7 +122,7 @@ static inline struct swap_slots_cache *get_slots_cache(int swap_type) if (swap_type == SWAP_TYPE_ALL) return raw_cpu_ptr(&swp_slots); else - return raw_cpu_ptr(&swp_type_slots)[swap_type]; + return raw_cpu_ptr(&swp_type_slots[swap_type]); }
static inline struct swap_slots_cache *get_slots_cache_cpu(unsigned int cpu,