linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaud Pouliquen <arnaud.pouliquen@st.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J . Wysocki" <rafael@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <arnaud.pouliquen@st.com>
Subject: [PATCH] component: fix debugfs.
Date: Wed, 18 Dec 2019 15:12:07 +0100	[thread overview]
Message-ID: <20191218141207.23156-1-arnaud.pouliquen@st.com> (raw)

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


             reply	other threads:[~2019-12-18 14:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-18 14:12 Arnaud Pouliquen [this message]
2020-01-14 15:09 ` [PATCH] component: fix debugfs Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191218141207.23156-1-arnaud.pouliquen@st.com \
    --to=arnaud.pouliquen@st.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).