]> www.infradead.org Git - users/dwmw2/linux.git/commit
tty: n_gsm: fix decoupled mux resource
authorDaniel Starke <daniel.starke@siemens.com>
Thu, 14 Apr 2022 09:42:08 +0000 (02:42 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 9 May 2022 07:05:07 +0000 (09:05 +0200)
commitf26c271492b6ec15c8bd274fd220b7835f5ebc3d
treefbca9424c2a3828f7d1acd696122ca6e7112eeb1
parent47132f9f7f766718513625982468f7f1339ca666
tty: n_gsm: fix decoupled mux resource

commit 1ec92e9742774bf42614fceea3bf6b50c9409225 upstream.

The active mux instances are managed in the gsm_mux array and via mux_get()
and mux_put() functions separately. This gives a very loose coupling
between the actual instance and the gsm_mux array which manages it. It also
results in unnecessary lockings which makes it prone to failures. And it
creates a race condition if more than the maximum number of mux instances
are requested while the user changes the parameters of an active instance.
The user may loose ownership of the current mux instance in this case.
Fix this by moving the gsm_mux array handling to the mux allocation and
deallocation functions.

Fixes: e1eaea46bb40 ("tty: n_gsm line discipline")
Cc: stable@vger.kernel.org
Signed-off-by: Daniel Starke <daniel.starke@siemens.com>
Link: https://lore.kernel.org/r/20220414094225.4527-3-daniel.starke@siemens.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/n_gsm.c