diff mbox

[1/2] of: Don't try to search when phandle == 0

Message ID 1412251931-6640-1-git-send-email-grant.likely@linaro.org
State Superseded
Headers show

Commit Message

Grant Likely Oct. 2, 2014, 12:12 p.m. UTC
A value of '0' isn't a valid phandle, so searching for a node with that
phandle is pointless. It will result in nothing but false positives.

Signed-off-by: Grant Likely <grant.likely@linaro.org>
---
 drivers/of/base.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Grant Likely Oct. 2, 2014, 12:13 p.m. UTC | #1
Oops. This is a standalone patch. Please ignore the [1/2] in the header.

g.

On Thu, Oct 2, 2014 at 1:12 PM, Grant Likely <grant.likely@linaro.org> wrote:
> A value of '0' isn't a valid phandle, so searching for a node with that
> phandle is pointless. It will result in nothing but false positives.
>
> Signed-off-by: Grant Likely <grant.likely@linaro.org>
> ---
>  drivers/of/base.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 293ed4b687ba..2305dc0382bc 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -1021,6 +1021,9 @@ struct device_node *of_find_node_by_phandle(phandle handle)
>         struct device_node *np;
>         unsigned long flags;
>
> +       if (!handle)
> +               return NULL;
> +
>         raw_spin_lock_irqsave(&devtree_lock, flags);
>         for (np = of_allnodes; np; np = np->allnext)
>                 if (np->phandle == handle)
> --
> 1.9.1
>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 293ed4b687ba..2305dc0382bc 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1021,6 +1021,9 @@  struct device_node *of_find_node_by_phandle(phandle handle)
 	struct device_node *np;
 	unsigned long flags;
 
+	if (!handle)
+		return NULL;
+
 	raw_spin_lock_irqsave(&devtree_lock, flags);
 	for (np = of_allnodes; np; np = np->allnext)
 		if (np->phandle == handle)