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

Tilman Schmidt <[email protected]> Sat, 12 Dec 2015 18:52:36 +0100
Newsgroups gmane.linux.kernel,gmane.linux.network,gmane.linux.isdn.i4l.user
Message-ID <[email protected]>
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: [email protected]
Bonn, Germany
Nous, on a des fleurs et des bougies pour nous protéger.
signature.asc (application/pgp-signature, 473 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJWbF70AAoJEFPuqx0v+F+qAQAH/1u4di4itW3HkcPQ2zfi/GbB
zsuCKZ3lvDpiq9b9svbQM8LzlPVJCGeus6SxuU/tADY0dZIgGRUXtDIvxCmCg/xQ
R0e+Pe6xCSZRVds/dAWux6OegZ1vLJHPp0rkbUtbvxrA6obfZ8QG1LVeGXnBPK0D
MdeIOZi97t/uUzs7VvKueFJ0tw/bNZOGnbqgDUcLcNpJYnw5X072DhM/QGgZPuUk
Bd5fkDpIXrZPh3PJLhycaXxUb6G5vqb+NVsL10/0pkAPMb+fAmek1CD0/lojc3Ut
EdSWEjIjSynVEYruemfstuQSVOpZjx1sngNHDitbCg9h4EEPnYsHAJAu7QCutWg=
=69AB
-----END PGP SIGNATURE-----