[PATCH] component: fix debugfs.

From: Arnaud Pouliquen
Date: Wed Dec 18 2019 - 09:13:05 EST


In component_devices_show function, the data field
of the component_match_array structure can not match with the
device structure type. As mentioned in component_match_add_release
description, data field type is undefined. This can result to an
unexpected print or can generate an overflow.
Seems no generic way to get the component name, so this patch
prints the component device name only if registered.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@xxxxxx>
---
drivers/base/component.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/base/component.c b/drivers/base/component.c
index 532a3a5d8f63..3ce4f75a6610 100644
--- a/drivers/base/component.c
+++ b/drivers/base/component.c
@@ -102,11 +102,13 @@ static int component_devices_show(struct seq_file *s, void *data)
seq_printf(s, "%-40s %20s\n", "device name", "status");
seq_puts(s, "-------------------------------------------------------------\n");
for (i = 0; i < match->num; i++) {
- struct device *d = (struct device *)match->compare[i].data;
+ struct component *comp = match->compare[i].component;

- seq_printf(s, "%-40s %20s\n", dev_name(d),
- match->compare[i].component ?
- "registered" : "not registered");
+ if (comp)
+ seq_printf(s, "%-40s %20s\n", dev_name(comp->dev),
+ "registered");
+ else
+ seq_printf(s, "%61s\n", "not registered");
}
mutex_unlock(&component_mutex);

--
2.17.1