linux/drivers/isdn/gigaset
Paul Bolle 8d2c3ab444 ser_gigaset: use container_of() instead of detour
The purpose of gigaset_device_release() is to kfree() the struct
ser_cardstate that contains our struct device. This is done via a bit of
a detour. First we make our struct device's driver_data point to the
container of our struct ser_cardstate (which is a struct cardstate). In
gigaset_device_release() we then retrieve that driver_data again. And
after that we finally kfree() the struct ser_cardstate that was saved in
the struct cardstate.

All of this can be achieved much easier by using container_of() to get
from our struct device to its container, struct ser_cardstate. Do so.

Note that at the time the detour was implemented commit b8b2c7d845
("base/platform: assert that dev_pm_domain callbacks are called
unconditionally") had just entered the tree. That commit disconnected
our platform_device and our platform_driver. These were reconnected
again in v4.5-rc2 through commit 25cad69f21 ("base/platform: Fix
platform drivers with no probe callback"). And one of the consequences
of that fix was that it broke the detour via driver_data. That's because
it made __device_release_driver() stop being a NOP for our struct device
and actually do stuff again. One of the things it now does, is setting
our driver_data to NULL. That, in turn, makes it impossible for
gigaset_device_release() to get to our struct cardstate. Which has the
net effect of leaking a struct ser_cardstate at every call of this
driver's tty close() operation. So using container_of() has the
additional benefit of actually working.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Tested-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
Acked-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-02-19 15:52:41 -05:00
..
Kconfig isdn/gigaset: enable Kernel CAPI support by default 2014-12-10 15:06:10 -05:00
Makefile gigaset: add Kernel CAPI interface (v3) 2009-10-06 22:43:53 -07:00
asyncdata.c isdn: whitespace coding style cleanup 2012-02-21 09:04:01 -08:00
bas-gigaset.c isdn/bas_gigaset: use USB API functions rather than constants 2014-08-22 12:23:10 -07:00
capi.c isdn/capi: handle CAPI 2.0 message parser failures 2014-10-14 15:05:35 -04:00
common.c isdn/gigaset: beautify common.c 2013-01-21 17:36:25 -05:00
dummyll.c isdn/gigaset: unify function return values 2012-05-07 22:37:56 -04:00
ev-layer.c isdn/gigaset: restructure modem response parser (4) 2015-03-23 16:47:24 -04:00
gigaset.h isdn/gigaset: drop duplicate declaration 2014-12-10 15:06:09 -05:00
i4l.c isdn/gigaset: unify function return values 2012-05-07 22:37:56 -04:00
interface.c TTY: add tty_port_tty_wakeup helper 2013-03-18 16:19:45 -07:00
isocdata.c isdn/gigaset: unify function return values 2012-05-07 22:37:56 -04:00
proc.c isdn: whitespace coding style cleanup 2012-02-21 09:04:01 -08:00
ser-gigaset.c ser_gigaset: use container_of() instead of detour 2016-02-19 15:52:41 -05:00
usb-gigaset.c isdn/gigaset: elliminate unnecessary argument from send_cb() 2014-12-10 15:06:09 -05:00