From 1982d050cc8c90ef269476bec87778e8c3ade5f7 Mon Sep 17 00:00:00 2001 From: Konsta Holtta Date: Mon, 17 Sep 2018 16:52:01 +0300 Subject: gpu: nvgpu: unit: deref twice in qsort callback The compare function for qsort takes pointers to compared elements, and our elements are already pointers so the void pointer has to be cast to a pointer pointer. Dereferencing only once would compare some data that's in the array of module pointers (or past it), not the actual data where the module pointers point to. Change-Id: I65678863eddd6fc86d4ffceb621f8123944b058d Signed-off-by: Konsta Holtta Reviewed-on: https://git-master.nvidia.com/r/1828164 Reviewed-by: svc-misra-checker GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: mobile promotions Tested-by: mobile promotions --- userspace/src/module.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/userspace/src/module.c b/userspace/src/module.c index e8e08a18..3f1cb782 100644 --- a/userspace/src/module.c +++ b/userspace/src/module.c @@ -102,10 +102,10 @@ static struct unit_module *load_one_module(struct unit_fw *fw, static int cmp_module_prio(const void *__mod_a, const void *__mod_b) { - const struct unit_module *mod_a = __mod_a; - const struct unit_module *mod_b = __mod_b; + const struct unit_module * const *mod_a = __mod_a; + const struct unit_module * const *mod_b = __mod_b; - return mod_a->prio > mod_b->prio; + return (*mod_a)->prio > (*mod_b)->prio; } /* -- cgit v1.2.2