linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: thomas.abraham@linaro.org (Thomas Abraham)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] of: fix incorrect return value of of_find_matching_node_and_match()
Date: Sat, 19 Jan 2013 10:20:42 -0800	[thread overview]
Message-ID: <1358619642-23607-1-git-send-email-thomas.abraham@linaro.org> (raw)

The of_find_matching_node_and_match() function incorrectly sets the matched
entry to 'matches' when the compatible value of a node matches one of the
possible values. This results in incorrectly selecting the the first entry in
the 'matches' list as the matched entry. Fix this by noting down the result of
the call to of_match_node() and setting that as the matched entry.

Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org>
---
 drivers/of/base.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 2390ddb..960ae5b 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -612,6 +612,7 @@ struct device_node *of_find_matching_node_and_match(struct device_node *from,
 					const struct of_device_id **match)
 {
 	struct device_node *np;
+	const struct of_device_id *m;
 
 	if (match)
 		*match = NULL;
@@ -619,9 +620,10 @@ struct device_node *of_find_matching_node_and_match(struct device_node *from,
 	read_lock(&devtree_lock);
 	np = from ? from->allnext : of_allnodes;
 	for (; np; np = np->allnext) {
-		if (of_match_node(matches, np) && of_node_get(np)) {
+		m = of_match_node(matches, np);
+		if (m && of_node_get(np)) {
 			if (match)
-				*match = matches;
+				*match = m;
 			break;
 		}
 	}
-- 
1.7.5.4

             reply	other threads:[~2013-01-19 18:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-19 18:20 Thomas Abraham [this message]
2013-01-19 18:27 ` [PATCH] of: fix incorrect return value of of_find_matching_node_and_match() Thomas Abraham
2013-01-20 21:50 ` Rob Herring
2013-01-20 21:56   ` Thomas Abraham
2013-01-21  3:27     ` Rob Herring
2013-01-21  3:48       ` Thomas Abraham

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=1358619642-23607-1-git-send-email-thomas.abraham@linaro.org \
    --to=thomas.abraham@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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).