diff mbox

mmc: tmio: Remove bogus un-initialization in tmio_mmc_host_free()

Message ID 1424277299-24964-1-git-send-email-geert+renesas@glider.be (mailing list archive)
State New, archived
Headers show

Commit Message

Geert Uytterhoeven Feb. 18, 2015, 4:34 p.m. UTC
If CONFIG_DEBUG_SLAB=y:

    sh_mobile_sdhi ee100000.sd: Got CD GPIO
    sh_mobile_sdhi ee100000.sd: Got WP GPIO
    platform ee100000.sd: Driver sh_mobile_sdhi requests probe deferral
    ...
    Slab corruption (Not tainted): kmalloc-1024 start=ed8b3c00, len=1024
    2d0: 00 00 00 00 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  ....kkkkkkkkkkkk
    Prev obj: start=ed8b3800, len=1024
    000: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
    010: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk

Struct tmio_mmc_host is embedded inside struct mmc_host, and thus is
freed by the call to mmc_free_host(). Hence it must not be written to
afterwards, as that will corrupt freed (and perhaps already reused)
memory.

Fixes: 94b110aff8679b14 ("mmc: tmio: add tmio_mmc_host_alloc/free()")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
 drivers/mmc/host/tmio_mmc_pio.c | 2 --
 1 file changed, 2 deletions(-)

Comments

Geert Uytterhoeven March 5, 2015, 10:08 a.m. UTC | #1
Ping?

On Wed, Feb 18, 2015 at 5:34 PM, Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> If CONFIG_DEBUG_SLAB=y:
>
>     sh_mobile_sdhi ee100000.sd: Got CD GPIO
>     sh_mobile_sdhi ee100000.sd: Got WP GPIO
>     platform ee100000.sd: Driver sh_mobile_sdhi requests probe deferral
>     ...
>     Slab corruption (Not tainted): kmalloc-1024 start=ed8b3c00, len=1024
>     2d0: 00 00 00 00 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  ....kkkkkkkkkkkk
>     Prev obj: start=ed8b3800, len=1024
>     000: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
>     010: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
>
> Struct tmio_mmc_host is embedded inside struct mmc_host, and thus is
> freed by the call to mmc_free_host(). Hence it must not be written to
> afterwards, as that will corrupt freed (and perhaps already reused)
> memory.
>
> Fixes: 94b110aff8679b14 ("mmc: tmio: add tmio_mmc_host_alloc/free()")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
>  drivers/mmc/host/tmio_mmc_pio.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
> index a31c3573d386f8c6..dba7e1c19dd758e7 100644
> --- a/drivers/mmc/host/tmio_mmc_pio.c
> +++ b/drivers/mmc/host/tmio_mmc_pio.c
> @@ -1073,8 +1073,6 @@ EXPORT_SYMBOL(tmio_mmc_host_alloc);
>  void tmio_mmc_host_free(struct tmio_mmc_host *host)
>  {
>         mmc_free_host(host->mmc);
> -
> -       host->mmc = NULL;
>  }
>  EXPORT_SYMBOL(tmio_mmc_host_free);
>
> --
> 1.9.1
--
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
Ulf Hansson March 5, 2015, 1:41 p.m. UTC | #2
On 18 February 2015 at 17:34, Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> If CONFIG_DEBUG_SLAB=y:
>
>     sh_mobile_sdhi ee100000.sd: Got CD GPIO
>     sh_mobile_sdhi ee100000.sd: Got WP GPIO
>     platform ee100000.sd: Driver sh_mobile_sdhi requests probe deferral
>     ...
>     Slab corruption (Not tainted): kmalloc-1024 start=ed8b3c00, len=1024
>     2d0: 00 00 00 00 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  ....kkkkkkkkkkkk
>     Prev obj: start=ed8b3800, len=1024
>     000: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
>     010: 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b  kkkkkkkkkkkkkkkk
>
> Struct tmio_mmc_host is embedded inside struct mmc_host, and thus is
> freed by the call to mmc_free_host(). Hence it must not be written to
> afterwards, as that will corrupt freed (and perhaps already reused)
> memory.
>
> Fixes: 94b110aff8679b14 ("mmc: tmio: add tmio_mmc_host_alloc/free()")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Applied, thanks!

Kind regards
Uffe

> ---
>  drivers/mmc/host/tmio_mmc_pio.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
> index a31c3573d386f8c6..dba7e1c19dd758e7 100644
> --- a/drivers/mmc/host/tmio_mmc_pio.c
> +++ b/drivers/mmc/host/tmio_mmc_pio.c
> @@ -1073,8 +1073,6 @@ EXPORT_SYMBOL(tmio_mmc_host_alloc);
>  void tmio_mmc_host_free(struct tmio_mmc_host *host)
>  {
>         mmc_free_host(host->mmc);
> -
> -       host->mmc = NULL;
>  }
>  EXPORT_SYMBOL(tmio_mmc_host_free);
>
> --
> 1.9.1
>
--
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/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c
index a31c3573d386f8c6..dba7e1c19dd758e7 100644
--- a/drivers/mmc/host/tmio_mmc_pio.c
+++ b/drivers/mmc/host/tmio_mmc_pio.c
@@ -1073,8 +1073,6 @@  EXPORT_SYMBOL(tmio_mmc_host_alloc);
 void tmio_mmc_host_free(struct tmio_mmc_host *host)
 {
 	mmc_free_host(host->mmc);
-
-	host->mmc = NULL;
 }
 EXPORT_SYMBOL(tmio_mmc_host_free);