Re: [PATCH] iio: core: use debugfs_remove_recursive() on IIO unload

From: Jonathan Cameron
Date: Sun Dec 15 2019 - 11:25:32 EST


On Wed, 11 Dec 2019 16:59:03 +0200
Alexandru Ardelean <alexandru.ardelean@xxxxxxxxxx> wrote:

> From: Lars-Peter Clausen <lars@xxxxxxxxxx>
>
> The debugfs dir may have multiple files/dirs attached to it. Use
> debugfs_remove_recursive() to clean it up when the IIO module unloads.
>
> Signed-off-by: Lars-Peter Clausen <lars@xxxxxxxxxx>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@xxxxxxxxxx>
> ---
>
> Note: note sure if this needs a Fixes tag. It's been in here for ages now,
> so it may not be a big issue.

There is some argument in favour of doing this as a defensive measure, but
in current IIO debugfs directories are only created by drivers that call
(indirectly) iio_device_register_debugfs and those must call
(again indirectly) iio_device_unregister_debugfs which has called
the recursive free on everything in their directories. So unless something
very odd is going on this isn't a bug.

Am I missing something?


>
> drivers/iio/industrialio-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 9a3579943574..dab67cb69fe6 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -292,7 +292,7 @@ static void __exit iio_exit(void)
> if (iio_devt)
> unregister_chrdev_region(iio_devt, IIO_DEV_MAX);
> bus_unregister(&iio_bus_type);
> - debugfs_remove(iio_debugfs_dentry);
> + debugfs_remove_recursive(iio_debugfs_dentry);
> }
>
> #if defined(CONFIG_DEBUG_FS)