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=1796383368; b=uqLQYvhiSs7Zv5bN1dadanV4uqb0qzLcFEzIuRCIspIkr7M0qz//u9cPmRTHiWIKcGP1 FcK5iOTu0zP5FqkMcs0yoKRNI5+nEOOcplIM0XmvuJTNv380+nfjM6hSbH1HM8n5dufYu vGr+CwPpca1mPCZSZAiE3cbwWquTfbFWuQrrsIbuqCAvm/uMQjVl/u6RXlsCgy6EGaYP1 vu9agaTwTdYk6uzWaLHPPo/f5+SWclX7XwODWW3HIX3f+u5Q3X5O7tHLVf2PPkx9V3LeV T3mGLhXsJd41j13bdZ9Yn/et5M9Jt511RFDmwDsW0P7Le3g+bjZ1Xtk2Y4BKZMdZlRg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383368; 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=ImK9VOw/khZxUMLLzpDy0h47avx3SHR8FWdMpP5U4G8=; b=FA337BHDvSZIHLmYXG7qHQcHoS7vNx8pjUg/7MMKTNx2coQSX4q5MxcfjGYxvw0xsPNd b2OA8V8tLitkZulIqqZ0Y+0gVE40QC3ci4P+oG0RTIIrwk3AwDVRsKdk7ylY9vELedfMH VFTi3nb9kpvxXy8VsnsHAXvkyzew5nug6xOK/8ycIJTaBsExDg0cbZBAM7B2jhkHVSKGM ZzDRh900qdm4OrLytCZsKDhrfbqrzg2WZDPfHhsb7MPfmENHZzoYcMyWL0E6TUX/4PFm3 Zq2Sn0loSbNI4hgGCOhY+cx1zJt71vkFwOQ/f8pspO8fsil36GQAaDCWis8xusrsYjQ== 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=vmJES3VJ; 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 B0AB1606A322; Fri, 4 Dec 2026 11:22:48 +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=vmJES3VJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E6D01F000C2; Fri, 4 Dec 2026 11:22:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383368; bh=ImK9VOw/khZxUMLLzpDy0h47avx3SHR8FWdMpP5U4G8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vmJES3VJjiIZ7NV90ZXjZGFsDuPhSlfHpsMbEIeFJShcbyTrJwmCGZGqh4Q3PjsvL LQ4XdPV+nWjWDOauukoLU56OAeyB23Rc5LncJCUQsebwB3Jm3uWFMoWN0rJAh+bxD6 o64ptKfMdwPFya2oSVy1Lj3fO1IjOKIOPd/PIPxE= 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 6.12 197/555] HID: sensor-hub: Synchronize callback removal with raw events Date: Fri, 4 Dec 2026 19:04:00 +0900 Message-ID: <20261204100615.714307032@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-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 faeb9c4536f52..9f14439cc0788 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