From 9694760eb8cd40aaf4ccca860f699d731fe1ab8f Mon Sep 17 00:00:00 2001 From: yinshengkai Date: Thu, 22 Aug 2024 21:06:40 +0800 Subject: [PATCH] input: fix touchevent race condition In touch_event, circbuf is operated, and there is a lack of protection here. Signed-off-by: yinshengkai --- drivers/input/touchscreen_upper.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/input/touchscreen_upper.c b/drivers/input/touchscreen_upper.c index 18e5471c22..d71c2d5363 100644 --- a/drivers/input/touchscreen_upper.c +++ b/drivers/input/touchscreen_upper.c @@ -375,6 +375,7 @@ static void touch_event_notify(FAR struct touch_openpriv_s *openpriv, { int semcount; + nxmutex_lock(&openpriv->lock); circbuf_overwrite(&openpriv->circbuf, sample, SIZEOF_TOUCH_SAMPLE_S(sample->npoints)); @@ -385,6 +386,7 @@ static void touch_event_notify(FAR struct touch_openpriv_s *openpriv, } poll_notify(&openpriv->fds, 1, POLLIN); + nxmutex_unlock(&openpriv->lock); } /****************************************************************************