Skip to content

Commit d038109

Browse files
Fabrizio CastroKAGA-KOKO
authored andcommitted
irqchip/renesas-rzg2l: Fix missing put_device
rzg2l_irqc_common_init() calls of_find_device_by_node(), but the corresponding put_device() call is missing. This also gets reported by make coccicheck. Make use of the cleanup interfaces from cleanup.h to call into __free_put_device(), which in turn calls into put_device when leaving function rzg2l_irqc_common_init() and variable "dev" goes out of scope. To prevent that the device is put on successful completion, assign NULL to "dev" to prevent __free_put_device() from calling into put_device() within the successful path. "make coccicheck" will still complain about missing put_device() calls, but those are false positives now. Fixes: 3fed095 ("irqchip: Add RZ/G2L IA55 Interrupt Controller driver") Signed-off-by: Fabrizio Castro <fabrizio.castro.jz@renesas.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Link: https://lore.kernel.org/all/20241011172003.1242841-1-fabrizio.castro.jz@renesas.com
1 parent a98a0f0 commit d038109

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

drivers/irqchip/irq-renesas-rzg2l.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
#include <linux/bitfield.h>
11+
#include <linux/cleanup.h>
1112
#include <linux/clk.h>
1213
#include <linux/err.h>
1314
#include <linux/io.h>
@@ -530,12 +531,12 @@ static int rzg2l_irqc_parse_interrupts(struct rzg2l_irqc_priv *priv,
530531
static int rzg2l_irqc_common_init(struct device_node *node, struct device_node *parent,
531532
const struct irq_chip *irq_chip)
532533
{
534+
struct platform_device *pdev = of_find_device_by_node(node);
535+
struct device *dev __free(put_device) = pdev ? &pdev->dev : NULL;
533536
struct irq_domain *irq_domain, *parent_domain;
534-
struct platform_device *pdev;
535537
struct reset_control *resetn;
536538
int ret;
537539

538-
pdev = of_find_device_by_node(node);
539540
if (!pdev)
540541
return -ENODEV;
541542

@@ -591,6 +592,17 @@ static int rzg2l_irqc_common_init(struct device_node *node, struct device_node *
591592

592593
register_syscore_ops(&rzg2l_irqc_syscore_ops);
593594

595+
/*
596+
* Prevent the cleanup function from invoking put_device by assigning
597+
* NULL to dev.
598+
*
599+
* make coccicheck will complain about missing put_device calls, but
600+
* those are false positives, as dev will be automatically "put" via
601+
* __free_put_device on the failing path.
602+
* On the successful path we don't actually want to "put" dev.
603+
*/
604+
dev = NULL;
605+
594606
return 0;
595607

596608
pm_put:

0 commit comments

Comments
 (0)