zswap: Add dynamic type conversion to solve the overflow 61/317461/1 accepted/tizen/unified/20250103.142709 accepted/tizen/unified/x/20250104.021608
authorUnsung Lee <unsung.lee@samsung.com>
Thu, 2 Jan 2025 06:32:08 +0000 (15:32 +0900)
committerUnsung Lee <unsung.lee@samsung.com>
Thu, 2 Jan 2025 08:23:32 +0000 (17:23 +0900)
Add dynamic type conversion from unsigned int to uint64_t to solve the
overflow problem. Previously, it tries to left shift operation
on a single unsigned int (32bit) variable by PAGE_SIZE bits,
it may cause an issue exceeding 32bit.

Change-Id: I29aa9e6c6c38db1fea4778bca896f91a21cde104
Signed-off-by: Unsung Lee <unsung.lee@samsung.com>
packaging/resourced.spec
src/resource-optimizer/memory/swap/zswap.c

index 3f503357ae773d9ad595ceea56a2ff3279511fe1..737c3fe8a6a180334e3296b8aa053b2c0a72a05c 100644 (file)
@@ -9,7 +9,7 @@
 
 Name:       resourced
 Summary:    Resource management daemon
-Version:    9.0.0
+Version:    9.0.1
 Release:    1
 Group:      System/Libraries
 License:    Apache-2.0
index 1451ba8ff34ac027e172d18db6347a090131c485..d48182eed27d85094fbbb8ab7d8908ede5e697f4 100644 (file)
@@ -96,7 +96,7 @@ static int swap_zswap_reclaim(void *data)
                return r;
        }
 
-       swap_size_bytes = swap_size_pages <<= PAGE_SHIFT;
+       swap_size_bytes = ((uint64_t) swap_size_pages) << PAGE_SHIFT;
        if (swap_size_bytes <= zswap_control.zswap_reclaim_bytes)
                return 0;