]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tracing: Fix mmiotrace possible NULL dereferencing of hiter->dev
authorSteven Rostedt <rostedt@goodmis.org>
Wed, 22 Jul 2026 01:11:43 +0000 (21:11 -0400)
committerSteven Rostedt <rostedt@goodmis.org>
Fri, 24 Jul 2026 17:43:09 +0000 (13:43 -0400)
If the mmio_pipe_open() fails to find a PCI device, the hiter->dev
will be assigned to NULL. The mmiotrace read() function dereferences the
hiter->dev if hiter exists.

Change the test of the read to not only check hiter being NULL, but also
the hiter->dev before dereferencing it.

Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260721211143.36dbd559@gandalf.local.home
Fixes: f984b51e0779 ("ftrace: add mmiotrace plugin")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/patchset/20260715143604.14481-1-gaikwad.dcg%40gmail.com
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/trace_mmiotrace.c

index 20812e7f911f1d2f111b919dda63ae2d55e0e62d..b88b8d9923adbd6e7cb4c321ff4ee16487e4b108 100644 (file)
@@ -145,7 +145,7 @@ static ssize_t mmio_read(struct trace_iterator *iter, struct file *filp,
                goto print_out;
        }
 
-       if (!hiter)
+       if (!hiter || !hiter->dev)
                return 0;
 
        mmio_print_pcidev(s, hiter->dev);