Calling qsort with NULL argument is invalid, although size 0 would
prevent anything bad from happening. Make sure that UBSAN is not
triggered.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/193
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
mod->sort_idx = i++;
}
- array_sort(&depmod->modules, mod_cmp);
- for (idx = 0; idx < depmod->modules.count; idx++) {
- struct mod *m = depmod->modules.array[idx];
- m->idx = idx;
+ if (depmod->modules.count > 1) {
+ array_sort(&depmod->modules, mod_cmp);
+ for (idx = 0; idx < depmod->modules.count; idx++) {
+ struct mod *m = depmod->modules.array[idx];
+ m->idx = idx;
+ }
}
corrupted: