From 7c80a6bfc0605380ab735a3f6732bf1ebb0380e9 Mon Sep 17 00:00:00 2001 From: Bard Liao Date: Tue, 15 Dec 2020 13:32:33 +0800 Subject: [PATCH] device property: Don't set secondary pointer if it is not NULL When we call set_primary_fwnode(dev, NULL) to remove a primary->NULL fwnode, "fn->secondary = ERR_PTR(-ENODEV);" will force primary->NULL become primary->ERR_PTR(-ENODEV) which is not what we expected. This patch doesn't impact removing primary->secondary->ERR_PTR(-ENODEV) fwnode. Signed-off-by: Bard Liao --- drivers/base/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index d661ada1518fb4..dda931abb60a79 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -4277,7 +4277,7 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode) } else { if (fwnode_is_primary(fn)) { dev->fwnode = fn->secondary; - if (!(parent && fn == parent->fwnode)) + if (!(parent && fn == parent->fwnode) && fn->secondary) fn->secondary = ERR_PTR(-ENODEV); } else { dev->fwnode = NULL;