Skip to content

Commit

Permalink
staging: vchiq_debugfs: Fix NPD in vchiq_dump_state
Browse files Browse the repository at this point in the history
The commit 42a2f66 ("staging: vc04_services: Move global g_state
to vchiq_state") falsely assumed that the debugfs entry vchiq/state
was created with vchiq_instance as data. This causes now a NULL
pointer derefence while trying to dump the vchiq state. So fix
this by passing vchiq_state as data, because this is the relevant
part here.

Fixes: 42a2f66 ("staging: vc04_services: Move global g_state to vchiq_state")
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Link: https://lore.kernel.org/r/20240524151542.19415-1-wahrenst@gmx.net
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Stefan Wahren authored and Greg Kroah-Hartman committed Jun 4, 2024
1 parent c3f38fa commit c3552ab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1759,7 +1759,7 @@ static int vchiq_probe(struct platform_device *pdev)
if (err)
goto failed_platform_init;

vchiq_debugfs_init();
vchiq_debugfs_init(&mgmt->state);

dev_dbg(&pdev->dev, "arm: platform initialised - version %d (min %d)\n",
VCHIQ_VERSION, VCHIQ_VERSION_MIN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ static int debugfs_trace_show(struct seq_file *f, void *offset)

static int vchiq_dump_show(struct seq_file *f, void *offset)
{
struct vchiq_instance *instance = f->private;
struct vchiq_state *state = f->private;

vchiq_dump_state(f, instance->state);
vchiq_dump_state(f, state);

return 0;
}
Expand Down Expand Up @@ -121,12 +121,12 @@ void vchiq_debugfs_remove_instance(struct vchiq_instance *instance)
debugfs_remove_recursive(node->dentry);
}

void vchiq_debugfs_init(void)
void vchiq_debugfs_init(struct vchiq_state *state)
{
vchiq_dbg_dir = debugfs_create_dir("vchiq", NULL);
vchiq_dbg_clients = debugfs_create_dir("clients", vchiq_dbg_dir);

debugfs_create_file("state", S_IFREG | 0444, vchiq_dbg_dir, NULL,
debugfs_create_file("state", S_IFREG | 0444, vchiq_dbg_dir, state,
&vchiq_dump_fops);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct vchiq_debugfs_node {
struct dentry *dentry;
};

void vchiq_debugfs_init(void);
void vchiq_debugfs_init(struct vchiq_state *state);

void vchiq_debugfs_deinit(void);

Expand Down

0 comments on commit c3552ab

Please sign in to comment.