android_kernel_oneplus_msm8998/drivers/isdn
Paul Bolle 6b3d1619c1 ser_gigaset: use container_of() instead of detour
[ Upstream commit 8d2c3ab4445640957d136caa3629857d63544a2a ]

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 25cad69f21f5 ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2018-11-10 07:41:34 -08:00
..
act2000 isdn: replace del_timer by del_timer_sync 2014-03-27 15:28:06 -04:00
capi isdn: kcapi: avoid uninitialized data 2017-12-25 14:22:13 +01:00
divert isdn: divert, hysdn: fix interruptible_sleep_on race 2014-02-26 16:06:13 -05:00
gigaset ser_gigaset: use container_of() instead of detour 2018-11-10 07:41:34 -08:00
hardware isdn: eicon: fix a missing-check bug 2018-06-13 16:15:28 +02:00
hisax isdn: Partially revert debug format string usage clean up 2015-11-25 11:49:58 -05:00
hysdn isdn: fix misspelling of current function in string 2014-12-09 16:18:46 -05:00
i4l isdn: Disable IIOCDBGVAR 2018-08-22 07:48:38 +02:00
icn isdn: icn: remove a #warning 2018-02-25 11:03:42 +01:00
isdnloop drivers: isdn: isdnloop: isdnloop.c: Remove parenthesis around return values, as specified in CodingStyle. 2015-02-05 15:40:23 -08:00
mISDN mISDN: Fix a sleep-in-atomic bug 2018-04-13 19:50:16 +02:00
pcbit isdn: fix misspelling of current function in string 2014-12-09 16:18:46 -05:00
sc isdn: sc: work around type mismatch warning 2018-02-25 11:03:51 +01:00
Kconfig tty: Added a CONFIG_TTY option to allow removal of TTY 2013-01-18 16:15:27 -08:00
Makefile