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=1796383162; b=xftetPz0yYiyj/0BnnyiUbtkZ1L8zt70PQFuyoQDh8P6MAmFkM7O768afKOO2Q3HtRm2 HsYk14uF9i0gnHV874/IV3Suu/ctcsV7HifC3tQK71+t0NJhVj4g53ZWj1gS/uAkzOZpe I+QpB6QW1A22n9cTD2u2t+WlpZpPoaavwJROPfcGlHbKjSeXbT9F096qO8C0pCKygsqAU +8RBYCBIvhF7dbh+5gB+GiIJAmg8JfUWJfBMujAO2777+LDZgn90E+zTUd822nyGQMg6C Q8ipo23Jin7t64OACCFn5gi06trOOAVuUsKDbPZZzQEAxJlZjeoAdTDkeZJ0JOycXmw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383162; 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=v3mtoZdeIXh8Ngl4g54LAcfltnxMpP0OgDn+jYco52M=; b=n8Hp4Z45ui7ih/oNcSpbiQgG7P8FOu4K+zy020Qh4YcS7K5sdJQaLFUtd4ayod6r4ZSx hkpPPatY1nUzriwzT5dlzVOtxBpBmMRs/gbni31sjnm0zyaPR5dOzo0J8Dns7GFbOyBNc bBsqnPExVOJuSQ3i0ISILWrgTGUSMIoVElJF20GN7XKdNzBiHR+jLIR2cKWQ6DFuTicLr B9viXyrdpvSP9BuHW0rRPer2z1RTNlnJXOypbGsuC5pt0dhZXmRhV/VgWHOQrD6XwlyMz mlY5JAwMOIi/2KgRZ4LUTV9upiXi2J9x52HDqOSoYfr73J0GFUc1WxzzkgZkX3grynw== 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=vHlAyjnx; 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 BB8B9606A338; Fri, 4 Dec 2026 11:19:22 +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=vHlAyjnx Received: by smtp.kernel.org (Postfix) with ESMTPSA id C8F0A1F00934; Fri, 4 Dec 2026 11:19:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383162; bh=v3mtoZdeIXh8Ngl4g54LAcfltnxMpP0OgDn+jYco52M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vHlAyjnxjPuXTHLcJl3BOfB66mpGeg1UGihabcYZE1y6wdN6Jo1cSGuopClQTIHL6 w9MkpKnMnCwIuKiD2NF7LJdiaPcaZbsXbJs5IDIyB8ek3suqCzTLK194UbU/kipffC gbJ8m7zUIh7Bn0+JrA5Og6MvhUDpB2I/qu0C7iuI= 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.12 108/555] iio: temperature: hid-sensor-temperature: Use per-instance callbacks Date: Fri, 4 Dec 2026 19:02:31 +0900 Message-ID: <20261204100611.780117329@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: 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.12-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: adapted to the older tree by using u64 timestamp __aligned(8) instead of aligned_s64 timestamp in the context, with a whitespace difference in the sensor_hub_register_callback argument alignment. ] 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 3cfd51236e4c8..546f50f0cc6f8 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; u64 timestamp __aligned(8); @@ -181,11 +182,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) { @@ -237,9 +233,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