Re: [PATCH] [extcon]:remove freed groups caused the panic or warningin unregister flow

From: Chanwoo Choi
Date: Sun Nov 03 2013 - 20:43:43 EST


Hi Wang,

> drivers/extcon/extcon-class.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
> index 148382f..48f4669 100644
> --- a/drivers/extcon/extcon-class.c
> +++ b/drivers/extcon/extcon-class.c
> @@ -794,6 +794,8 @@ void extcon_dev_unregister(struct extcon_dev *edev)
> return;
> }
>
> + device_unregister(edev->dev);
> +
> if (edev->mutually_exclusive && edev->max_supported) {
> for (index = 0; edev->mutually_exclusive[index];
> index++)
> @@ -814,7 +816,6 @@ void extcon_dev_unregister(struct extcon_dev *edev)
> if (switch_class)
> class_compat_remove_link(switch_class, edev->dev, NULL);
> #endif
> - device_unregister(edev->dev);
> put_device(edev->dev);
> }
> EXPORT_SYMBOL_GPL(extcon_dev_unregister);
>

I think we could only apply following patch instead of moving the position of device_unregister().

diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
index 148382f..ff27b19 100644
--- a/drivers/extcon/extcon-class.c
+++ b/drivers/extcon/extcon-class.c
@@ -805,10 +805,8 @@ void extcon_dev_unregister(struct extcon_dev *edev)
for (index = 0; index < edev->max_supported; index++)
kfree(edev->cables[index].attr_g.name);

- if (edev->max_supported) {
- kfree(edev->extcon_dev_type.groups);
+ if (edev->max_supported)
kfree(edev->cables);
- }

#if defined(CONFIG_ANDROID)
if (switch_class)

Thanks,
Chanwoo Choi

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/