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()
Unified · Split
| @@ -4264,9 +4264,9 @@ static inline bool fwnode_is_primary(struct fwnode_handle *fwnode) · 4263 unmodified lines | ||
| 4264 | 4264 | */ |
| 4265 | 4265 | void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode) |
| 4266 | 4266 | { |
| 4267 | − if (fwnode) { | |
| 4268 | − struct fwnode_handle *fn = dev->fwnode; | |
| 4267 | + struct fwnode_handle *fn = dev->fwnode; | |
| 4269 | 4268 | |
| 4269 | + if (fwnode) { | |
| 4270 | 4270 | if (fwnode_is_primary(fn)) |
| 4271 | 4271 | fn = fn->secondary; |
| 4272 | 4272 | |
| @@ -4276,8 +4276,12 @@ void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode) · 3 unmodified lines | ||
| 4276 | 4276 | } |
| 4277 | 4277 | dev->fwnode = fwnode; |
| 4278 | 4278 | } else { |
| 4279 | − dev->fwnode = fwnode_is_primary(dev->fwnode) ? | |
| 4280 | − dev->fwnode->secondary : NULL; | |
| 4279 | + if (fwnode_is_primary(fn)) { | |
| 4280 | + dev->fwnode = fn->secondary; | |
| 4281 | + fn->secondary = NULL; | |
| 4282 | + } else { | |
| 4283 | + dev->fwnode = NULL; | |
| 4284 | + } | |
| 4281 | 4285 | } |
| 4282 | 4286 | } |
| 4283 | 4287 | EXPORT_SYMBOL_GPL(set_primary_fwnode); |