ACPI: EC: Reference count query handlers under lock
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 27 Dec 2019 10:04:21 +0000 (11:04 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 1 Oct 2020 18:40:05 +0000 (20:40 +0200)
commit0516e42c7b0263721cee45429ac97eed6aff603c
tree1146e309aaf22f816ae583b68ef6e965e2ae301c
parent318a2c03e3827d41431ab2b56c52a91157d4fb2f
ACPI: EC: Reference count query handlers under lock

[ Upstream commit 3df663a147fe077a6ee8444ec626738946e65547 ]

There is a race condition in acpi_ec_get_query_handler()
theoretically allowing query handlers to go away before refernce
counting them.

In order to avoid it, call kref_get() on query handlers under
ec->mutex.

Also simplify the code a bit while at it.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/acpi/ec.c