Bluetooth: fix init and cleanup of sco_conn.timeout_work
authorDesmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
Fri, 3 Sep 2021 03:13:06 +0000 (23:13 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Nov 2021 18:16:22 +0000 (19:16 +0100)
commit11080de0a75cba7e00c1060d60ea484615d7a3d3
tree198457717ec7bfe01942fae4f58c9060d2f5da5a
parent5f14a2c4648cb7001fd20de0cc0429bfcd92bf7e
Bluetooth: fix init and cleanup of sco_conn.timeout_work

[ Upstream commit 49d8a5606428ca0962d09050a5af81461ff90fbb ]

Before freeing struct sco_conn, all delayed timeout work should be
cancelled. Otherwise, sco_sock_timeout could potentially use the
sco_conn after it has been freed.

Additionally, sco_conn.timeout_work should be initialized when the
connection is allocated, not when the channel is added. This is
because an sco_conn can create channels with multiple sockets over its
lifetime, which happens if sockets are released but the connection
isn't deleted.

Fixes: ba316be1b6a0 ("Bluetooth: schedule SCO timeouts with delayed_work")
Signed-off-by: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/bluetooth/sco.c