From: Steven Rostedt <[email protected]>

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: [email protected]
Fixes: f984b51e0779 ("ftrace: add mmiotrace plugin")
Reported-by: Sashiko
Link: 
https://sashiko.dev/#/patchset/20260715143604.14481-1-gaikwad.dcg%40gmail.com
Signed-off-by: Steven Rostedt <[email protected]>
---
 kernel/trace/trace_mmiotrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
index 20812e7f911f..b88b8d9923ad 100644
--- a/kernel/trace/trace_mmiotrace.c
+++ b/kernel/trace/trace_mmiotrace.c
@@ -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);
-- 
2.53.0


Reply via email to