]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
platform/chrome: cros_ec_rpmsg: Fix race with host command when probe failed
authorPi-Hsun Shih <pihsun@chromium.org>
Wed, 4 Sep 2019 06:26:13 +0000 (14:26 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 5 Oct 2019 11:14:17 +0000 (13:14 +0200)
commit8c4f7f403e79ebd36760267e9026145dc99be6b8
treee64c0bf71cc377a0f673bb75ec5985dacc03dbae
parentd4ecc0a011cc1115e3be0a79b3a01e17b326f074
platform/chrome: cros_ec_rpmsg: Fix race with host command when probe failed

[ Upstream commit 71cddb7097e2b0feb855d7fd7d59afd12cbee4bb ]

Since the rpmsg_endpoint is created before probe is called, it's
possible that a host event is received during cros_ec_register, and
there would be some pending work in the host_event_work workqueue while
cros_ec_register is called.

If cros_ec_register fails, when the leftover work in host_event_work
run, the ec_dev from the drvdata of the rpdev could be already set to
NULL, causing kernel crash when trying to run cros_ec_get_next_event.

Fix this by creating the rpmsg_endpoint by ourself, and when
cros_ec_register fails (or on remove), destroy the endpoint first (to
make sure there's no more new calls to cros_ec_rpmsg_callback), and then
cancel all works in the host_event_work workqueue.

Cc: stable@vger.kernel.org
Fixes: 2de89fd98958 ("platform/chrome: cros_ec: Add EC host command support using rpmsg")
Signed-off-by: Pi-Hsun Shih <pihsun@chromium.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/platform/chrome/cros_ec_rpmsg.c