Re: [PATCH] mmc: alcor: Fix a resource leak in an error handling path in 'alcor_pci_sdmmc_drv_probe()'

From: Markus Elfring
Date: Mon Apr 27 2020 - 01:54:51 EST


> If 'devm_request_threaded_irq()' fails, resources allocated by
> 'mmc_alloc_host()' must be freed.

How do you think about a wording variant like the following?

Subject:
[PATCH v2] mmc: alcor: Complete exception handling in alcor_pci_sdmmc_drv_probe()

Change description (according to a solution alternative):
The exception handling was incomplete in an if branch
after a failed call of the function âdevm_request_threaded_irqâ.
Thus add a call of the function âmmc_free_hostâ for the release of
corresponding system resources.


> +++ b/drivers/mmc/host/alcor.c
> @@ -1104,7 +1104,7 @@ static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev)
>
> if (ret) {
> dev_err(&pdev->dev, "Failed to get irq for data line\n");
> - return ret;
> + goto free_host;
> }
>
> mutex_init(&host->cmd_mutex);

You propose to perform a jump to other code only once in this implementation.
I find it more succinct to call the desired function then directly.

dev_err(â);
+ mmc_free_host(mmc);
return ret;


Regards,
Markus