diff mbox series

zsmalloc: use temporary unsigned long for min_alloc_size calculations

Message ID 20221031021438.376636-1-senozhatsky@chromium.org (mailing list archive)
State New
Headers show
Series zsmalloc: use temporary unsigned long for min_alloc_size calculations | expand

Commit Message

Sergey Senozhatsky Oct. 31, 2022, 2:14 a.m. UTC
kbuild reported the following warning:

mm/zsmalloc.c: In function 'zs_create_pool':
mm/zsmalloc.c:2220:69: warning: right shift count >= width of type [-Wshift-count-overflow]

Use unsigned long temp variable for calculations in zs_create_pool().

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
 mm/zsmalloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 0bc9ed1f1a5d..181bfc66249b 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -2211,6 +2211,7 @@  struct zs_pool *zs_create_pool(const char *name, u32 max_pages_per_zspage)
 	int i;
 	struct zs_pool *pool;
 	struct size_class *prev_class = NULL;
+	unsigned long num_pages = max_pages_per_zspage;
 
 	if (WARN_ON(max_pages_per_zspage < ZS_MIN_PAGES_PER_ZSPAGE ||
 		    max_pages_per_zspage > ZS_MAX_PAGES_PER_ZSPAGE))
@@ -2221,8 +2222,7 @@  struct zs_pool *zs_create_pool(const char *name, u32 max_pages_per_zspage)
 		return NULL;
 
 	/* min_alloc_size must be multiple of ZS_ALIGN */
-	pool->min_alloc_size = (max_pages_per_zspage << PAGE_SHIFT) >>
-		OBJ_INDEX_BITS;
+	pool->min_alloc_size = num_pages << PAGE_SHIFT >> OBJ_INDEX_BITS;
 	pool->min_alloc_size = max(pool->min_alloc_size, ZS_MIN_ALLOC_SIZE);
 
 	pool->num_size_classes =