[igt-dev] [PATCH i-g-t 2/8] lib/igt_kmod.c: check if module is builtin before attempting to unload it

Mauro Carvalho Chehab mauro.chehab at linux.intel.com
Mon Jun 5 10:56:12 UTC 2023


On Mon,  5 Jun 2023 12:47:10 +0200
Dominik Karol Piatkowski <dominik.karol.piatkowski at intel.com> wrote:

> From: Isabella Basso <isabbasso at riseup.net>
> 
> This change makes `igt_kmod_unload_r` safer as it checks whether the
> module can be unloaded before attempting it.
> 
> v2 -> v3:
> - Fix commit message
> - Make return value clearer
> 
> Acked-by: Janusz Krzysztofik <janusz.krzysztofik at linux.intel.com>
Acked-by: Mauro Carvalho Chehab <mchehab at kernel.org>

> Signed-off-by: Isabella Basso <isabbasso at riseup.net>
> 
> Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski at intel.com>
> ---
>  lib/igt_kmod.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
> index 93fa2006..26d58e29 100644
> --- a/lib/igt_kmod.c
> +++ b/lib/igt_kmod.c
> @@ -259,6 +259,9 @@ static int igt_kmod_unload_r(struct kmod_module *kmod, unsigned int flags)
>  	int err, tries;
>  	const char *mod_name = kmod_module_get_name(kmod);
>  
> +	if (kmod_module_get_initstate(kmod) == KMOD_MODULE_BUILTIN)
> +		return 0;
> +
>  	holders = kmod_module_get_holders(kmod);
>  	kmod_list_foreach(pos, holders) {
>  		struct kmod_module *it = kmod_module_get_module(pos);


More information about the igt-dev mailing list