Sean noted that scripts/Makefile.lib:name-fix-token rule will mangle the module name with s/-/_/g. Since this happens late in the build, only the kernel needs to bother with this, the modpost tool still sees the original name.
Unified · Split
| @@ -169,6 +169,30 @@ static inline void add_taint_module(struct module *mod, unsigned flag, · 168 unmodified lines | ||
| 169 | 169 | set_bit(flag, &mod->taints); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | +/* | |
| 173 | + * Like strncmp(), except s/-/_/g as per scripts/Makefile.lib:name-fix-token rule. | |
| 174 | + */ | |
| 175 | +static int mod_strncmp(const char *str_a, const char *str_b, size_t n) | |
| 176 | +{ | |
| 177 | + for (int i = 0; i < n; i++) { | |
| 178 | + char a = str_a[i]; | |
| 179 | + char b = str_b[i]; | |
| 180 | + int d; | |
| 181 | + | |
| 182 | + if (a == '-') a = '_'; | |
| 183 | + if (b == '-') b = '_'; | |
| 184 | + | |
| 185 | + d = a - b; | |
| 186 | + if (d) | |
| 187 | + return d; | |
| 188 | + | |
| 189 | + if (!a) | |
| 190 | + break; | |
| 191 | + } | |
| 192 | + | |
| 193 | + return 0; | |
| 194 | +} | |
| 195 | + | |
| 172 | 196 | /* |
| 173 | 197 | * A thread that wants to hold a reference to a module only while it |
| 174 | 198 | * is running can call this to safely exit. |
| @@ -1116,7 +1140,7 @@ static bool verify_module_namespace(const char *namespace, const char *modname) · 941 unmodified lines | ||
| 1116 | 1140 | if (*sep) |
| 1117 | 1141 | sep++; |
| 1118 | 1142 | |
| 1119 | − if (strncmp(namespace, modname, len) == 0 && (glob || len == modlen)) | |
| 1143 | + if (mod_strncmp(namespace, modname, len) == 0 && (glob || len == modlen)) | |
| 1120 | 1144 | return true; |
| 1121 | 1145 | } |
| 1122 | 1146 | |