Re: [PATCH 2/3] ser_gigaset: fix deallocation of platform device structure

From: Tilman Schmidt
Date: Sat Dec 12 2015 - 12:53:03 EST


Hi Peter,

Am 10.12.2015 um 15:04 schrieb Peter Hurley:

>>>> --- a/drivers/isdn/gigaset/ser-gigaset.c
>>>> +++ b/drivers/isdn/gigaset/ser-gigaset.c
>>>> @@ -370,19 +370,23 @@ static void gigaset_freecshw(struct cardstate
>>>> *cs)
>>>> tasklet_kill(&cs->write_tasklet);
>>>> if (!cs->hw.ser)
>>>> return;
>>>> - dev_set_drvdata(&cs->hw.ser->dev.dev, NULL);
>>>> platform_device_unregister(&cs->hw.ser->dev);
>>>> - kfree(cs->hw.ser);
>>>> - cs->hw.ser = NULL;
>>>> }
>>>>
>>>> static void gigaset_device_release(struct device *dev)
>>>> {
>>>> struct platform_device *pdev = to_platform_device(dev);
>>>> + struct cardstate *cs = dev_get_drvdata(dev);
>>>>
>>>> /* adapted from platform_device_release() in
>>>> drivers/base/platform.c */
>>>> kfree(dev->platform_data);
>>>> kfree(pdev->resource);
>>>> +
>>>> + if (!cs)
>>>> + return;
>>>> + dev_set_drvdata(dev, NULL);
>
> This is of marginal value and (I think) unnecessary; it implies
> the core will use the device after release, which would trigger
> many problems if true.

Agreed, but I'm just moving existing code here. Dropping the
dev_set_drvdata() call would be an unrelated change which should be done
in a separate patch if I understand the rules correctly.

Regards,
Tilman

--
Tilman Schmidt E-Mail: tilman@xxxxxxx
Bonn, Germany
Nous, on a des fleurs et des bougies pour nous protÃger.

Attachment: signature.asc
Description: OpenPGP digital signature