All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] component: fix debugfs.
@ 2019-12-18 14:12 Arnaud Pouliquen
  2020-01-14 15:09 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Arnaud Pouliquen @ 2019-12-18 14:12 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki; +Cc: linux-kernel, arnaud.pouliquen

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@st.com>
---
 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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] component: fix debugfs.
  2019-12-18 14:12 [PATCH] component: fix debugfs Arnaud Pouliquen
@ 2020-01-14 15:09 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2020-01-14 15:09 UTC (permalink / raw)
  To: Arnaud Pouliquen; +Cc: Rafael J . Wysocki, linux-kernel

On Wed, Dec 18, 2019 at 03:12:07PM +0100, Arnaud Pouliquen wrote:
> 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@st.com>

Good catch, someone else fixed this right before you did, so I'll queue
up that patch, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-01-14 15:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-18 14:12 [PATCH] component: fix debugfs Arnaud Pouliquen
2020-01-14 15:09 ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.