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=1796381573; b=PRWrsW4aMZgTbvRxvSZpXAX7BYRSsrjdGBlq00IVRXHyX0VGPl+0kodsJjqvZZbEHQ6u XCt3tihsRo5+25HvCQAAaPoRi+7PSuFeRUawpMJ3V+1lamtwc59XXSTAu30bIRu+s70vw i2f4BTSusvutxGmza5GMaJuqQOj1kSonP+P03UhoWF7jwGdjpdv/yaG+e885ZnhjYOEv9 UYbHQbbf3rtymKYrdx6EdwUZKgrbrzYPQaKGtqNnN5XdhA0KFw/u+1rNh5fxL+FXqaRSl d9GfPcrzuByg3A3ACa1K1CLuZWmu0PTMRuwNUHe9O3u4AQwtTL0V2aqIHbTKXNggGCw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381573; 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=LXV1FbFiTcpUp6lZS5sTvizJvxeHF5FsfK7aHJp/ebc=; b=39zesh7Vpscf6Ri6uVtd7CI/R4x6Wjj5cv1G9xqRYLnQtT5zi9nfgBV0JpQzpcan6Vbk 0x03RZryS2M9rgTX13UueRHXPZ3VSv3gMmE26AMP3t7ZGisOLVb4ucz5SSIqH02fJw/qd Axc9SfBH8SQi9g7PW172AtDBc+X+P8y6i3siwYplnwXh2cObQx76fPm7rEzQ3s3js0vvV C0QdOQfQDm6djF0Xbq14yXnAA4ttkvWSewI7ChrRUqXDAZQ0IxKeU0yfLkEnD4o9TvTYt +m68BJ6Jedy0cGuW5gjPG+chgbTWGycocOfmFl07F1zIYye/zKeSY3l3Kv3UCTOV+Yg== 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=TudQxUad; 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 10C3A606A32D; Fri, 4 Dec 2026 10:52:53 +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=TudQxUad Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7BB271F000CE; Fri, 4 Dec 2026 10:52:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381572; bh=LXV1FbFiTcpUp6lZS5sTvizJvxeHF5FsfK7aHJp/ebc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TudQxUadU4Innq7oecYF/3WK0DZK0cTeaimPiRoG8PBl106g0RfzAmxik5NqXXHrU 0eB4fLqz3Hbu9qv7kceqDrjUAYcNB38czViJMtUiITEToCwCY6Ic86J1FWslYtRARG EQ9YYcaF82iflF/JvXA0cKYLaHHloYEecXZcYr4w= 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.18 082/703] iio: temperature: hid-sensor-temperature: Use per-instance callbacks Date: Fri, 4 Dec 2026 18:59:41 +0900 Message-ID: <20261204100629.915867778@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christopher Hoover [ Upstream commit 36eeb26031e90eeb81bbac3d3acad61d23fcbdf3 ] hid-sensor-temperature keeps a single static struct hid_sensor_hub_callbacks for all instances and overwrites its pdev in every probe. With two temperature sensors, input reports for one are delivered with the other's platform device; once that device is removed, platform_get_drvdata() returns NULL and temperature_capture_sample() dereferences it: BUG: kernel NULL pointer dereference, address: 00000000000003a8 RIP: 0010:temperature_capture_sample+0xd/0x50 [hid_sensor_temperature] The oops happens in sensor_hub_raw_event() with the hub's spinlock held, so the hub's removal then hangs. It reproduces with two uhid devices that each declare a temperature sensor, one destroyed while the other still sends input reports. Keep the callbacks in struct temperature_state, as the other HID sensor drivers (accel, gyro, als, ...) do. Fixes: 59d0f2da3569 ("iio: hid: Add temperature 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: Applied cleanly with only line offsets and a re-indented removed context line (&temperature_callbacks);) because the base file differs; the resulting code matches upstream. ] Signed-off-by: Sasha Levin --- drivers/iio/temperature/hid-sensor-temperature.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/iio/temperature/hid-sensor-temperature.c b/drivers/iio/temperature/hid-sensor-temperature.c index 34bff7e9f3a33..2b3478c6902cc 100644 --- a/drivers/iio/temperature/hid-sensor-temperature.c +++ b/drivers/iio/temperature/hid-sensor-temperature.c @@ -16,6 +16,7 @@ struct temperature_state { struct hid_sensor_common common_attributes; struct hid_sensor_hub_attribute_info temperature_attr; + struct hid_sensor_hub_callbacks callbacks; struct { s32 temperature_data; aligned_s64 timestamp; @@ -182,11 +183,6 @@ static int temperature_parse_report(struct platform_device *pdev, return ret; } -static struct hid_sensor_hub_callbacks temperature_callbacks = { - .send_event = &temperature_proc_event, - .capture_sample = &temperature_capture_sample, -}; - /* Function to initialize the processing for usage id */ static int hid_temperature_probe(struct platform_device *pdev) { @@ -238,9 +234,13 @@ static int hid_temperature_probe(struct platform_device *pdev) platform_set_drvdata(pdev, indio_dev); - temperature_callbacks.pdev = pdev; + temp_st->callbacks = (struct hid_sensor_hub_callbacks) { + .send_event = temperature_proc_event, + .capture_sample = temperature_capture_sample, + .pdev = pdev, + }; ret = sensor_hub_register_callback(hsdev, HID_USAGE_SENSOR_TEMPERATURE, - &temperature_callbacks); + &temp_st->callbacks); if (ret) goto error_remove_trigger; -- 2.53.0