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=1796386310; b=wsqskBp/N112QOP8TmrYMEPNcgzpqm8UD0MsLujmtWPZoKmXlXBWMcOJuy2vQINL1KRD kOZeRgtN8PexiVQZ0LE3g/Qk7AQIQo+qAVMQagkU+wyPdhvz+5apzl9HbCjCOv3f59Lh5 8PtuMqvS2H9pK43j9tRh8t+wucd3qmwLYAFHAG+2beSgPaVkitgHp7S18znFNHBgmawFm CJ53bQbVZKgcGhxa8TOlSgrIt1qXrbV1zdiLYSv/R6dYP+8s3isLcg65T97q6diIkyR3u x1wMyMfPGX8yUD0vBRNtH2QQvr7GVUlkqh11sHNoYWycPmKp43P+i0MPL4RYIU2VHVQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386310; 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=3GLjvAx8AZLznjax8KewRKSmNEN/V1D7TQrVzZpeCO0=; b=LYEMLd/bk8QO6ylTrAmwTAFD/TE9xwX3e1iRTTyKnUE2aRC1sA+jwJ3oWj8iSWXzlEXC HD9Fz8OXNT/tQZfJQw64tHL9Ey6AIxF8OUGnm993pk5aAeIoDsvhxN+UmhegdVuCXO8sT iovSq2LB8RLFrRegcV0lEoGWBrZZmEAC3o/NS3Iv8qgK/SbWcdPgwOTU3A5VzHBJoXStQ NDJ5RN9wzPkpGWdqQkgvf0ns/eEnApRT79b5gqnSb/+gJbQwdc1gIKdhA6KF+6dFmlXHJ i6SMzFGbdb2sJBlZj7u/rUW1LU31DvuY5Cl4y6DFB5+FVtQ3M9IgQWQXgLxn48WGOsw== 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=jdmQIveJ; 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 2842B606A322; Fri, 4 Dec 2026 12:11:50 +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=jdmQIveJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B8DF1F00931; Fri, 4 Dec 2026 12:11:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386310; bh=3GLjvAx8AZLznjax8KewRKSmNEN/V1D7TQrVzZpeCO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jdmQIveJUzctLKTpKEA+aeQukg+1CuAHnmFz2X1AkPUVjJj/62AmiumdxuSO8STkj KATFIYB1X32SeaD109C+pHm5862cQ3+KWJFWu9DZRPijMD8qoxIRULT7mIyggBbW1N GwA0sSMO/Oi/C4xZWgVB/5UFXbRHUrYky2tkEhnU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Semyon Maryasin , Zhang Lixu , Srinivas Pandruvada , Jonathan Cameron , Jiri Kosina , Sasha Levin Subject: [PATCH 6.6 0910/1167] HID: sensor-hub: Remove clients before stopping hardware Date: Fri, 4 Dec 2026 19:05:37 +0900 Message-ID: <20261204100725.904616833@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Srinivas Pandruvada [ Upstream commit 41cb3076a221afba052ae1624ccf62e500706b20 ] Remove MFD clients before stopping the HID hardware so their close calls remain valid. Runtime-PM teardown may cancel a pending autosuspend without running the client suspend callback, leaving hub references after child removal. Clients share one HID open while ref_cnt is nonzero. After removing the children, drain any remaining references and call hid_hw_close() once if the count is nonzero. Then stop the HID hardware. This avoids both a leaked open and the underflow caused by an unconditional close. The pending-request walk runs before hid_hw_stop() disconnects HID-core children such as hidraw. Skip non-platform children and platform children without sensor-hub data before checking pending request state. Fixes: 1df3a401154a ("HID: Delay opening HID device") Reported-by: Semyon Maryasin Closes: https://lore.kernel.org/all/CAM2dg7ewfVJSP4rFyhkCB1Rmd1+X56sAg=eUdbPthG2xrLqwQQ@mail.gmail.com/ 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 | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index fd4597eeb104e..3909a0e0ca152 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include "hid-ids.h" @@ -808,7 +809,14 @@ static int sensor_hub_probe(struct hid_device *hdev, static int sensor_hub_finalize_pending_fn(struct device *dev, void *data) { - struct hid_sensor_hub_device *hsdev = dev->platform_data; + struct hid_sensor_hub_device *hsdev; + + if (!dev_is_platform(dev)) + return 0; + + hsdev = to_platform_device(dev)->dev.platform_data; + if (!hsdev) + return 0; if (hsdev->pending.status) complete(&hsdev->pending.ready); @@ -822,8 +830,6 @@ static void sensor_hub_remove(struct hid_device *hdev) unsigned long flags; hid_dbg(hdev, " hardware removed\n"); - hid_hw_close(hdev); - hid_hw_stop(hdev); spin_lock_irqsave(&data->lock, flags); device_for_each_child(&hdev->dev, NULL, @@ -831,6 +837,14 @@ static void sensor_hub_remove(struct hid_device *hdev) spin_unlock_irqrestore(&data->lock, flags); mfd_remove_devices(&hdev->dev); + /* Clients share one HID open; release it if references remain. */ + mutex_lock(&data->mutex); + if (data->ref_cnt) { + data->ref_cnt = 0; + hid_hw_close(hdev); + } + mutex_unlock(&data->mutex); + hid_hw_stop(hdev); mutex_destroy(&data->mutex); } -- 2.53.0