Skip to content

Commit ef9ffc1

Browse files
lkundrakgregkh
authored andcommitted
component: do not dereference opaque pointer in debugfs
The match data does not have to be a struct device pointer, and indeed very often is not. Attempt to treat it as such easily results in a crash. For the components that are not registered, we don't know which device is missing. Once it it is there, we can use the struct component to get the device and whether it's bound or not. Fixes: 59e7385 ('component: add debugfs support') Signed-off-by: Lubomir Rintel <[email protected]> Cc: stable <[email protected]> Cc: Arnaud Pouliquen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e2f3733 commit ef9ffc1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/base/component.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ static int component_devices_show(struct seq_file *s, void *data)
101101
seq_printf(s, "%-40s %20s\n", "device name", "status");
102102
seq_puts(s, "-------------------------------------------------------------\n");
103103
for (i = 0; i < match->num; i++) {
104-
struct device *d = (struct device *)match->compare[i].data;
104+
struct component *component = match->compare[i].component;
105105

106-
seq_printf(s, "%-40s %20s\n", dev_name(d),
107-
match->compare[i].component ?
108-
"registered" : "not registered");
106+
seq_printf(s, "%-40s %20s\n",
107+
component ? dev_name(component->dev) : "(unknown)",
108+
component ? (component->bound ? "bound" : "not bound") : "not registered");
109109
}
110110
mutex_unlock(&component_mutex);
111111

0 commit comments

Comments
 (0)