]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
spi: fix statistics allocation
authorJohan Hovold <johan@kernel.org>
Thu, 12 Mar 2026 15:18:14 +0000 (16:18 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Mar 2026 10:08:49 +0000 (11:08 +0100)
commitdf30056c78e8bead02d4be020199cabdbec0fef1
tree6a50df51e6e92ebb30de8d8d8e76334f37024e36
parentafe27c1f43aa57530011f419be6ddf71306565d2
spi: fix statistics allocation

commit dee0774bbb2abb172e9069ce5ffef579b12b3ae9 upstream.

The controller per-cpu statistics is not allocated until after the
controller has been registered with driver core, which leaves a window
where accessing the sysfs attributes can trigger a NULL-pointer
dereference.

Fix this by moving the statistics allocation to controller allocation
while tying its lifetime to that of the controller (rather than using
implicit devres).

Fixes: 6598b91b5ac3 ("spi: spi.c: Convert statistics to per-cpu u64_stats_t")
Cc: stable@vger.kernel.org # 6.0
Cc: David Jander <david@protonic.nl>
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20260312151817.32100-3-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/spi/spi.c