From patchwork Sat Jan 19 18:20:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Abraham X-Patchwork-Id: 2007261 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 0ADB03FE4F for ; Sat, 19 Jan 2013 18:24:49 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Twd2M-0006IX-4S; Sat, 19 Jan 2013 18:21:02 +0000 Received: from mail-pb0-f43.google.com ([209.85.160.43]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Twd2H-0006I6-FW for linux-arm-kernel@lists.infradead.org; Sat, 19 Jan 2013 18:20:58 +0000 Received: by mail-pb0-f43.google.com with SMTP id jt11so1234883pbb.16 for ; Sat, 19 Jan 2013 10:20:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=bR5vAj+z0IU7azKAMqTGwgOID4SnN2Yj8xCUtAXuIC0=; b=VUMMyUwi8oge2NDdP05M1PAujJSV4pv59UHZcJc1bCqsGHXtm5BsNVsJ4eCgDAq4NC 0hiPVwbGA5/0FgEVqvpephYnnWmMUAFl7mCOxHOO0ZaCGNgv01PjNpclTdl8juelx/fm r/alsSejLeSZVaiebSjdNspb+Z8W3IZoVpKc0tvMoOqGuROK7jwOupF6wfFKwv99bGzO ikULC76u6RIxArgZNpMNlcrM2HcNwerap3MhLpP8zZloicWA6S9AKpLB8gWYMzqCfhpv nXhxcgW3WycEKZZjBhAJvz/s+83a8AWQxEwv6N9IRcvIvBbX0H+2eptx/9vlEeOVQh3H gVKg== X-Received: by 10.68.203.137 with SMTP id kq9mr16441730pbc.115.1358619654659; Sat, 19 Jan 2013 10:20:54 -0800 (PST) Received: from localhost.localdomain (72-254-18-128.client.stsn.net. [72.254.18.128]) by mx.google.com with ESMTPS id nf9sm5372623pbc.17.2013.01.19.10.20.53 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 19 Jan 2013 10:20:53 -0800 (PST) From: 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 Message-Id: <1358619642-23607-1-git-send-email-thomas.abraham@linaro.org> X-Mailer: git-send-email 1.7.5.4 X-Gm-Message-State: ALoCoQlraGlCXCPcp0rZNYkYKk3kNdrLSXRQNFIGlbITIctMAOJZy5qM54LaW4fWf9r4WP0StEAD X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130119_132057_609986_E9A371C4 X-CRM114-Status: GOOD ( 11.82 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.43 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: grant.likely@secretlab.ca, rob.herring@calxeda.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 --- 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; } }