From 980c39fbb3f15eb63848f850268374f51f07cbd3 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Wed, 11 Dec 2024 11:21:00 +0100 Subject: [PATCH] LU-18086 sec: fix warning message for insufficient memory If even the very first pool cannot be allocated, then pool_order is 0. So fix warning message in this case, as reported by Coverity: CoverityID: 451725 ("Integer handling issues") In expression "0x1000UL << pool_order - 1", shifting by a negative amount has undefined behavior. The shift amount, "pool_order - 1", is -1. Fixes: 1a6ae4b3eb ("LU-18086 sec: do not allocate empty pools") Test-Parameters: trivial Signed-off-by: Sebastien Buisson Change-Id: I45a8cf45cae3a8ed07b170d852ec5e1d096da656 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/57368 Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Reviewed-by: Sergey Cheremencev Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo --- lustre/obdclass/page_pools.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lustre/obdclass/page_pools.c b/lustre/obdclass/page_pools.c index 3a6d132..37d5090 100644 --- a/lustre/obdclass/page_pools.c +++ b/lustre/obdclass/page_pools.c @@ -1080,7 +1080,8 @@ int obd_pool_init(void) */ if (!pool->opp_max_ptr_pages) { CWARN("Cannot allocate pool %i, not enough memory. Max available compression chunk is %lu.\n", - pool_order, PAGE_SIZE << (pool_order - 1)); + pool_order, + pool_order ? PAGE_SIZE << (pool_order - 1) : 0); pools_count = pool_order; OBD_FREE(pool, sizeof(**page_pools)); break; -- 1.8.3.1