Skip to content

Commit 02cbf8e

Browse files
Lorenzo PieralisiKAGA-KOKO
authored andcommitted
irqchip/msi-lib: Fix fwnode refcount in msi_lib_irq_domain_select()
Commit 8b65db1 ("irqchip/msi-lib: Add IRQ_DOMAIN_FLAG_FWNODE_PARENT handling") added logic in msi_lib_irq_domain_select() to match the domain fwnode against the fwnode parent of the fwspec.fwnode. The fwnode_get_parent() caller must call fwnode_handle_put() on the returned pointer value, lest fwnode refcounting for the parent ends up being out of kilter. Fix this by relying on the fwnode_handle clean-up handlers and by incrementing the fwnode refcount regardless of whether parent matching is used or not (the domain selection code already holds a reference before calling msi_lib_irq_domain_select() but to make the exit path more uniform if IRQ_DOMAIN_FLAG_FWNODE_PARENT is not set fwnode_handle_get() is called again on fwspec.fwnode so that the clean-up code is the same for the two matching patterns). Fixes: 8b65db1 ("irqchip/msi-lib: Add IRQ_DOMAIN_FLAG_FWNODE_PARENT handling") Signed-off-by: Lorenzo Pieralisi <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Link: https://lore.kernel.org/all/[email protected]
1 parent cb9f6a4 commit 02cbf8e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/irqchip/irq-msi-lib.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ int msi_lib_irq_domain_select(struct irq_domain *d, struct irq_fwspec *fwspec,
133133
{
134134
const struct msi_parent_ops *ops = d->msi_parent_ops;
135135
u32 busmask = BIT(bus_token);
136-
struct fwnode_handle *fwh;
137136

138137
if (!ops)
139138
return 0;
140139

141-
fwh = d->flags & IRQ_DOMAIN_FLAG_FWNODE_PARENT ? fwnode_get_parent(fwspec->fwnode)
142-
: fwspec->fwnode;
140+
struct fwnode_handle *fwh __free(fwnode_handle) =
141+
d->flags & IRQ_DOMAIN_FLAG_FWNODE_PARENT ? fwnode_get_parent(fwspec->fwnode)
142+
: fwnode_handle_get(fwspec->fwnode);
143143
if (fwh != d->fwnode || fwspec->param_count != 0)
144144
return 0;
145145

0 commit comments

Comments
 (0)