[Intel-xe] [PATCH] drm/xe: Call exit functions when xe_register_pci_driver() fails

Jani Nikula jani.nikula at linux.intel.com
Wed May 10 13:22:08 UTC 2023


On Tue, 09 May 2023, Gustavo Sousa <gustavo.sousa at intel.com> wrote:
> Make sure all necessary exit functions are also called when
> xe_register_pci_driver() fails.
>
> Signed-off-by: Gustavo Sousa <gustavo.sousa at intel.com>
> ---
>  drivers/gpu/drm/xe/xe_module.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_module.c b/drivers/gpu/drm/xe/xe_module.c
> index 6860586ce7f8..9698875852d3 100644
> --- a/drivers/gpu/drm/xe/xe_module.c
> +++ b/drivers/gpu/drm/xe/xe_module.c
> @@ -53,14 +53,18 @@ static int __init xe_init(void)
>  
>  	for (i = 0; i < ARRAY_SIZE(init_funcs); i++) {
>  		err = init_funcs[i].init();
> -		if (err) {
> -			while (i--)
> -				init_funcs[i].exit();
> -			return err;
> -		}
> +		if (err)
> +			break;
>  	}
>  
> -	return xe_register_pci_driver();
> +	if (!err)
> +		err = xe_register_pci_driver();

Why aren't xe_register_pci_driver() and xe_unregister_pci_driver()
init/exit functions in the array? It would avoid the special casing
here, and allow some init functions to be called after register.

BR,
Jani.


> +
> +	if (err)
> +		while (i--)
> +			init_funcs[i].exit();
> +
> +	return err;
>  }
>  
>  static void __exit xe_exit(void)

-- 
Jani Nikula, Intel Open Source Graphics Center


More information about the Intel-xe mailing list