]> git.baikalelectronics.ru Git - kernel.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>
Fri, 15 Apr 2022 06:36:04 +0000 (08:36 +0200)
commit285eeb52ac45f11cddcdb9e9a2e60167fc68f226
tree9d6b74a34a704d7c61d3736d73d4eb61c8a0eb5f
parente5205668a20c6682f3938188ad33ef6119c450d0
tty: n_gsm: fix decoupled mux resource

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: 99551fa31543 ("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