]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mmc: cd-gpio: protect against NULL context in mmc_cd_gpio_free()
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Tue, 24 Apr 2012 15:56:29 +0000 (17:56 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Jun 2012 07:15:53 +0000 (15:15 +0800)
commit 0e9f480bb553d39ee06ccd45639ba7a5446a7b81 upstream.

Do not oops, even if mmc_cd_gpio_free() is mistakenly called on a driver
cleanup path, even though a previous call to mmc_cd_gpio_request() failed.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
[stable@: please apply to 3.3-stable]
Signed-off-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mmc/core/cd-gpio.c

index 082202ae4a03cbc9fb5a4a32f3276e27bec98508..8c3e6f0ff78ed6767df807799d55c30f841ed1ec 100644 (file)
@@ -67,6 +67,9 @@ void mmc_cd_gpio_free(struct mmc_host *host)
 {
        struct mmc_cd_gpio *cd = host->hotplug.handler_priv;
 
+       if (!cd)
+               return;
+
        free_irq(host->hotplug.irq, host);
        gpio_free(cd->gpio);
        kfree(cd);