Skip to contentSkip to conversation

lib/igt_kmod: Compare module names with strcmp

PATCH In review Ander Conselvan de Oliveira 3 participants 3 messages Feb 3, 2017 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/igt_kmod: Compare module names with strcmp

The function igt_kmod_is_loaded() returns the wrong value when there is a module loaded whose name is a prefix of the name supplied as a paremter. For instance, if the "snd" module is loaded, igt_kmod_is_load("snd_hda_intel") will return true even if that module isn't loaded, thus causing drv_module_reload to failure in that scenario.

---
 lib/igt_kmod.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/igt_kmod.c +1 -1
index 657a0e5..5981700 100644
@@ -91,7 +91,7 @@ igt_kmod_is_loaded(const char *mod_name)
 		struct kmod_module *kmod = kmod_module_get_module(mod);
 		const char *kmod_name = kmod_module_get_name(kmod);
 
-		if (!strncmp(kmod_name, mod_name, strlen(kmod_name))) {
+		if (!strcmp(kmod_name, mod_name)) {
 			kmod_module_unref(kmod);
 			ret = true;
 			break;
Signature · 6 lines
2.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Ander Conselvan de Oliveira

The function igt_kmod_is_loaded() returns the wrong value when there is a module loaded whose name is a prefix of the name supplied as a paremter. For instance, if the "snd" module is loaded, igt_kmod_is_load("snd_hda_intel") will return true even if that module isn't loaded, thus causing drv_module_reload to failure in that scenario.

Ah, that would explain some of the mystery.

Quoted 1 line

-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw
Quoted 8 lines · Chris Wilson
Quoted 6 lines · Ander Conselvan de Oliveira

The function igt_kmod_is_loaded() returns the wrong value when there is a module loaded whose name is a prefix of the name supplied as a paremter. For instance, if the "snd" module is loaded, igt_kmod_is_load("snd_hda_intel") will return true even if that module isn't loaded, thus causing drv_module_reload to failure in that scenario.

Quoted 6 lines

Ah, that would explain some of the mystery.

Quoted 2 lines

l.com>

Thanks. Pushed with commit message typos fixed.

Ander
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx