From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380116; b=SFjvUUlV5rvpQO7duTzkaJalOJ8q/SkVNzVsTWhmLZXcj/DdkA5NJTFZMVI2mpT0YpSr r1Ux2yYGOiGybNn0eVmu3JyllbAdRm3x2e3rCgOrtJoH3IIJA68bQuOcvin/aEqtHX4tl 62l6HDx0F+SVz5gxpVQ4LOPdn5ydypb8DMLB0R+iYF2s5WPdWYVuK899nV2LMxViRAjmr kiQwekTIyi8b5eq9aUfVhyEJwDs0s2X75Wep+ThgTEQszvYDZsdtQR4V/MWf+lBRkw6hz 6TVv9+mgDTAgDrTRK0AKnOUO3sK5JghaFq5+lBvD0Oo2CMTxv4D1o+3tfuQXQP/McQQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380116; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=+vgkHvAPpIjrYAU8VBOhQbTjjkm75QxR24ZqO/hjmyg=; b=e7OICS3RpExR3PvmGZsen3n+PcZNlxWOMpe6sjKl0+pA5x5rjC8B0Bd7smPIk+vKqC/o lN0OAlb0YdSYmHr6wLjgO9cSVGm8oatkNj3EsofxUUgIOXXVEqAv5o/UkIw6ivSiTmtm3 B5tElwZxOdTGoqs5N3yS4Rdn7mlinnBH+UvgzHkHgXPd0vnRKbBCC2lXe4p813mF4du78 +n+cSAMQgJZrhw/wO4t4h5pG7HgCkCe9tZqwSw1kDipQUcfj4buAXuZMkZ/XvggrLIrnz 1+VtnSHx1Z7ch9k5zSNztGScPBBrhVFTdw+KLaaJwY61Esyag8DTIsr/m44W/YCDTPg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=j3pzhha8; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B421C606A332; Fri, 4 Dec 2026 10:28:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=j3pzhha8 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E81A71F0092C; Fri, 4 Dec 2026 10:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380116; bh=+vgkHvAPpIjrYAU8VBOhQbTjjkm75QxR24ZqO/hjmyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=j3pzhha8zZTN7MEWDuntmvD4veX8cpETLOfl2YH3FQ4WNKU1jkOclA6Ci0LlAgjAU cyb3mDeilFYTd7kImxAcQPmkNiRGO33+TfpkGh+RQxDLI21CEK0vF08quyxfm8XGPN KpziOtJo3bEwHj5VizH43sM8tQek4njsW+pdKA+M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Semyon Maryasin , Joshua Crofts , Zhang Lixu , Srinivas Pandruvada , Jonathan Cameron , Jiri Kosina , Sasha Levin Subject: [PATCH 7.3 131/742] HID: sensor-hub: Synchronize callback removal with raw events Date: Fri, 4 Dec 2026 18:59:55 +0900 Message-ID: <20261204100638.612424744@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Srinivas Pandruvada [ Upstream commit abe10ad9c5fd868553b1262df403d5aaea3eff64 ] Raw-event processing holds pdata->lock across callback lookup and invocation, and takes dyn_callback_lock during lookup. Removal must prevent both active callbacks and future lookups before client state can be released. Take pdata->lock before dyn_callback_lock, matching raw-event order, and unlink the callback while holding both locks. This ensures active raw-event callbacks have finished and prevents future lookups. Fixes: 401ca24fb34a ("HID: sensors: introduce sensor framework") Reported-by: Semyon Maryasin Closes: https://lore.kernel.org/all/CAM2dg7ewfVJSP4rFyhkCB1Rmd1+X56sAg=eUdbPthG2xrLqwQQ@mail.gmail.com/ Reviewed-by: Joshua Crofts Tested-by: Semyon Maryasin Tested-by: Zhang Lixu Signed-off-by: Srinivas Pandruvada Reviewed-by: Jonathan Cameron Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-sensor-hub.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index 6470a290ebfc5..0c4884c5821fd 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c @@ -173,7 +173,9 @@ int sensor_hub_remove_callback(struct hid_sensor_hub_device *hsdev, struct sensor_hub_data *pdata = hid_get_drvdata(hsdev->hdev); unsigned long flags; - spin_lock_irqsave(&pdata->dyn_callback_lock, flags); + /* Serialize callback removal with raw-event callback execution. */ + spin_lock_irqsave(&pdata->lock, flags); + spin_lock(&pdata->dyn_callback_lock); list_for_each_entry(callback, &pdata->dyn_callback_list, list) if (callback->usage_id == usage_id && callback->hsdev == hsdev) { @@ -181,7 +183,8 @@ int sensor_hub_remove_callback(struct hid_sensor_hub_device *hsdev, kfree(callback); break; } - spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags); + spin_unlock(&pdata->dyn_callback_lock); + spin_unlock_irqrestore(&pdata->lock, flags); return 0; } -- 2.53.0