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=1796388820; b=cSG0/JcRCODjwZlwCw7h6OuRUgF2VnpK5/CmmikZE+t0BklnWRHqw5pocJjxaDYMC+TO +S01BdtiAoECbyT0zvR0dD4wqXJvgleNaKclMibXiDZcASJmJh3WwHFL0SEnyIIb7mYpq pCcWEj4cwhzH19DF3QJK1fEXnIEq0irh9gI1qJdcVhQ35lPe7e/iK8PQ9lf62xzdZ145S BvHGK2kY8IatN5eoVqd/2qXH25fWZ2gS05E5+wAbuWhyq8SXRQfRC6jJZsXVVWx5bH7sx 9J+ndc7ALI4YoCZ3jdLGmW8uBrSvZn/uf9apnaeqbsIcU6QgDhe1P0eK1+HbdGzLiOw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388820; 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=BwmUZjhNPx/KzoxIJDIO4p2kd9iHt6f7L7NOAtAehBY=; b=jYaX6PM9UFbXdDPm0/Ud5AcyRTdpT6wfkAh63hHXaaZYB6Yn5mRE08vN6x5nZIHYm27E UezRxb+nVXBuhB3LHLyEbL4p3ziRh58BowQF7f0m93nNMqITxnOoE44KihohCSjFdJwvk qm9DLJqBleEzAcqGKCtTAIlHfCBP/IHKvxFsmAdcZ+E5+VRucTMti26suiCN5RfXkk5O8 rulutsF5/TgL2Ar1ZERkdUg5xZxrNb2TUsB3uN5fVVDlWpn7BHsJVjetkLv64tOCGVHs2 JQzUPMGOnmBDdKz26uo55rmMUNBuVbSQ06OMzIZ0G2ekI2PAfbEtCpgywVpXDYN6SDw== 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=EGnqpStI; 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 CCD08606A32C; Fri, 4 Dec 2026 12:53:40 +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=EGnqpStI Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBC0B1F000CE; Fri, 4 Dec 2026 12:53:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388820; bh=BwmUZjhNPx/KzoxIJDIO4p2kd9iHt6f7L7NOAtAehBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=EGnqpStIXKjj+qBMjBwB7X/3qVx9GNhn+B8cmTS55COr0rXXHp6IpOB04KeEyvRI9 QX9Us/ObfNRpdmalFa411EjNGxWHKLmlv+SvsdMen76yohbmyIVFVwLWq0HCPrKbrN lMo6bfxPJS/3JSmODi3M3YZ/kO2A6YUZKpPGVNZU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Christopher Hoover , Joshua Crofts , Srinivas Pandruvada , Jonathan Cameron , Sasha Levin Subject: [PATCH 6.1 0765/1059] iio: humidity: hid-sensor-humidity: Use per-instance callbacks Date: Fri, 4 Dec 2026 19:04:56 +0900 Message-ID: <20261204100703.827497551@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christopher Hoover [ Upstream commit bbe4f3f668babc9443fc1f075695e43e17ca7976 ] hid-sensor-humidity keeps a single static struct hid_sensor_hub_callbacks for all instances and overwrites its pdev in every probe, so with two humidity sensors, input reports for one are delivered with the other's platform device, and a NULL dereference follows once that device is removed. The same bug was found in hid-sensor-temperature, which shares this code. Keep the callbacks in struct hid_humidity_state, as the other HID sensor drivers (accel, gyro, als, ...) do. Fixes: d7ed89d5aadf ("iio: hid: Add humidity sensor support") Cc: stable@vger.kernel.org Signed-off-by: Christopher Hoover Reviewed-by: Joshua Crofts Acked-by: Srinivas Pandruvada Signed-off-by: Jonathan Cameron [ sashal: Adapted the timestamp field from aligned_s64 timestamp to u64 timestamp __aligned(8), and adjusted whitespace in the sensor_hub_register_callback() argument alignment. ] Signed-off-by: Sasha Levin --- drivers/iio/humidity/hid-sensor-humidity.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/iio/humidity/hid-sensor-humidity.c b/drivers/iio/humidity/hid-sensor-humidity.c index fa0fe404a70a2..b13b20a36ddfd 100644 --- a/drivers/iio/humidity/hid-sensor-humidity.c +++ b/drivers/iio/humidity/hid-sensor-humidity.c @@ -16,6 +16,7 @@ struct hid_humidity_state { struct hid_sensor_common common_attributes; struct hid_sensor_hub_attribute_info humidity_attr; + struct hid_sensor_hub_callbacks callbacks; struct { s32 humidity_data; u64 timestamp __aligned(8); @@ -184,11 +185,6 @@ static int humidity_parse_report(struct platform_device *pdev, return ret; } -static struct hid_sensor_hub_callbacks humidity_callbacks = { - .send_event = &humidity_proc_event, - .capture_sample = &humidity_capture_sample, -}; - /* Function to initialize the processing for usage id */ static int hid_humidity_probe(struct platform_device *pdev) { @@ -240,9 +236,13 @@ static int hid_humidity_probe(struct platform_device *pdev) platform_set_drvdata(pdev, indio_dev); - humidity_callbacks.pdev = pdev; + humid_st->callbacks = (struct hid_sensor_hub_callbacks) { + .send_event = humidity_proc_event, + .capture_sample = humidity_capture_sample, + .pdev = pdev, + }; ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_HUMIDITY, - &humidity_callbacks); + &humid_st->callbacks); if (ret) goto error_remove_trigger; -- 2.53.0