[RAMEN9610-14454] [COMMON] sched: ems: Fix possibility of slab-out-of-bounds error
authorDaeyeong Lee <daeyeong.lee@samsung.com>
Tue, 20 Nov 2018 07:13:33 +0000 (16:13 +0900)
committerCosmin Tanislav <demonsingur@gmail.com>
Mon, 22 Apr 2024 17:24:57 +0000 (20:24 +0300)
Change-Id: Ieeecdd4d811479d3e23d2638ff93069e75c5cedf
Signed-off-by: Daeyeong Lee <daeyeong.lee@samsung.com>
kernel/sched/ems/load_balance.c

index 848f5ca4cb0c2d316ea1569891798640ce8bd512..dc79023f83341489368effae92c326a07a476ad6 100644 (file)
@@ -137,9 +137,12 @@ static inline int get_topology_depth(void)
 
 static inline int get_last_level(struct lbt_overutil *ou)
 {
-       int level;
+       int level, depth = get_topology_depth();
+
+       for (level = 0; level <= depth ; level++) {
+               if (&ou[level] == NULL)
+                       return -1;
 
-       for (level = 0; &ou[level] != NULL; level++) {
                if (ou[level].top == true)
                        return level;
        }