diff mbox

[2/2] mmc: core: fix error path in mmc_host_alloc

Message ID 92cb6f74-a354-d4ab-6e40-1d985526e68f@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Heiner Kallweit Jan. 28, 2017, 8:32 a.m. UTC
Properly reverse everything if mmc_gpio_alloc(host) fails.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/mmc/core/host.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Ulf Hansson Jan. 30, 2017, 10:05 a.m. UTC | #1
On 28 January 2017 at 09:32, Heiner Kallweit <hkallweit1@gmail.com> wrote:
> Properly reverse everything if mmc_gpio_alloc(host) fails.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Thanks, applied for next!

Kind regards
Uffe

> ---
>  drivers/mmc/core/host.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
> index 0a26c8b6..19c68bf2 100644
> --- a/drivers/mmc/core/host.c
> +++ b/drivers/mmc/core/host.c
> @@ -369,6 +369,8 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
>
>         if (mmc_gpio_alloc(host)) {
>                 put_device(&host->class_dev);
> +               ida_simple_remove(&mmc_host_ida, host->index);
> +               kfree(host);
>                 return NULL;
>         }
>
> --
> 2.11.0
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 0a26c8b6..19c68bf2 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -369,6 +369,8 @@  struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
 
 	if (mmc_gpio_alloc(host)) {
 		put_device(&host->class_dev);
+		ida_simple_remove(&mmc_host_ida, host->index);
+		kfree(host);
 		return NULL;
 	}