From eb8b3efece4626b5628c65d0ac7d94912528f7ee Mon Sep 17 00:00:00 2001 From: Sami Tolvanen Date: Tue, 11 Feb 2020 12:12:51 -0800 Subject: [PATCH] lib/list_sort: fix function type mismatches Casting the comparison function to a different type trips indirect call Control-Flow Integrity (CFI) checking. Remove the additional consts from cmp_func, and the now unneeded casts. Change-Id: Ie21cfb8bbc75632e4d96b44cf3f0c3d3331d7fa0 Fixes: 043b3f7 ("lib/list_sort: simplify and remove MAX_LIST_LENGTH_BITS") Signed-off-by: Sami Tolvanen i Git-commit: 5bc3f3591d783484b2e0011f3b5633c1e60e7585 Git-repo: https://github.com/samitolvanen/linux.git Signed-off-by: Prakruthi Deepak Heragu --- lib/list_sort.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/list_sort.c b/lib/list_sort.c index 52f0c258c895..4c1b941392b0 100644 --- a/lib/list_sort.c +++ b/lib/list_sort.c @@ -8,7 +8,7 @@ #include typedef int __attribute__((nonnull(2,3))) (*cmp_func)(void *, - struct list_head const *, struct list_head const *); + struct list_head *, struct list_head *); /* * Returns a list organized in an intermediate format suited @@ -227,7 +227,7 @@ void list_sort(void *priv, struct list_head *head, if (likely(bits)) { struct list_head *a = *tail, *b = a->prev; - a = merge(priv, (cmp_func)cmp, b, a); + a = merge(priv, cmp, b, a); /* Install the merged result in place of the inputs */ a->prev = b->prev; *tail = a; @@ -249,7 +249,7 @@ void list_sort(void *priv, struct list_head *head, if (!next) break; - list = merge(priv, (cmp_func)cmp, pending, list); + list = merge(priv, cmp, pending, list); pending = next; } /* The final merge, rebuilding prev links */