Re: [PATCH V14 04/24] mmc: block: Ensure that debugfs files are removed

From: Linus Walleij
Date: Thu Nov 23 2017 - 08:22:41 EST


On Tue, Nov 21, 2017 at 2:42 PM, Adrian Hunter <adrian.hunter@xxxxxxxxx> wrote:

> The card is not necessarily being removed, but the debugfs files must be
> removed when the driver is removed, otherwise they will continue to exist
> after unbinding the card from the driver. e.g.
>
> # echo "mmc1:0001" > /sys/bus/mmc/drivers/mmcblk/unbind
> # cat /sys/kernel/debug/mmc1/mmc1\:0001/ext_csd
> [ 173.634584] BUG: unable to handle kernel NULL pointer dereference at 0000000000000050
> [ 173.643356] IP: mmc_ext_csd_open+0x5e/0x170
>
> A complication is that the debugfs_root may have already been removed, so
> check for that too.
>
> Fixes: 627c3ccfb46a ("mmc: debugfs: Move block debugfs into block module")
> Signed-off-by: Adrian Hunter <adrian.hunter@xxxxxxxxx>

Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx>

I was assuming debugfs would always be removed from debugfs.c
using debugfs_remove_recursive(card->debugfs_root) but that
doesn't work for this case where we bin/unbind the block layer
interactively, sorry for missing it :(

Ulf: I think this can go in as an *early* fix as well, say after -rc1.

Yours,
Linus Walleij