diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2020-08-28 13:23:31 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2020-08-28 13:23:31 -0700 |
commit | 005c53447a63cbce10de37406975a34d7bdc8704 (patch) | |
tree | 83bddd274b46b343bff3281c47a526f39e8e471c | |
parent | 0b2f18e7aeef86f966bbfccec8d698e05ccc4631 (diff) | |
parent | c15e1bdda4365a5f17cdadf22bf1c1df13884a9e (diff) |
Merge tag 'devprop-5.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull device properties framework fix from Rafael Wysocki:
"Prevent the promotion of the secondary firmware node of a device to
the primary one from leaking a pointer (Heikki Krogerus)"
* tag 'devprop-5.9-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
device property: Fix the secondary firmware node handling in set_primary_fwnode()
-rw-r--r-- | drivers/base/core.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c index ac1046a382bc..f6f620aa9408 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -4264,9 +4264,9 @@ static inline bool fwnode_is_primary(struct fwnode_handle *fwnode) */ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode) { - if (fwnode) { - struct fwnode_handle *fn = dev->fwnode; + struct fwnode_handle *fn = dev->fwnode; + if (fwnode) { if (fwnode_is_primary(fn)) fn = fn->secondary; @@ -4276,8 +4276,12 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode) } dev->fwnode = fwnode; } else { - dev->fwnode = fwnode_is_primary(dev->fwnode) ? - dev->fwnode->secondary : NULL; + if (fwnode_is_primary(fn)) { + dev->fwnode = fn->secondary; + fn->secondary = NULL; + } else { + dev->fwnode = NULL; + } } } EXPORT_SYMBOL_GPL(set_primary_fwnode); |