From: Marc Zyngier <maz@kernel.org>
To: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Chris Paterson <Chris.Paterson2@renesas.com>,
Biju Das <biju.das.jz@bp.renesas.com>,
"linux-renesas-soc@vger.kernel.org"
<linux-renesas-soc@vger.kernel.org>
Subject: Re: [PATCH] irqchip/renesas-rzg2l: Fix missing put_device
Date: Sun, 06 Oct 2024 16:53:42 +0100 [thread overview]
Message-ID: <861q0t6xdl.wl-maz@kernel.org> (raw)
In-Reply-To: <TYCPR01MB120935A52A777BF62344B05C3C2772@TYCPR01MB12093.jpnprd01.prod.outlook.com>
On Tue, 01 Oct 2024 12:54:30 +0100,
Fabrizio Castro <fabrizio.castro.jz@renesas.com> wrote:
>
> Hi Marc,
>
> thank you for your reply.
>
> > From: Marc Zyngier <maz@kernel.org>
> > Sent: Monday, September 30, 2024 8:15 PM
> > To: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
> > Subject: Re: [PATCH] irqchip/renesas-rzg2l: Fix missing put_device
> >
> > On Mon, 30 Sep 2024 17:36:20 +0100,
> > Fabrizio Castro <fabrizio.castro.jz@renesas.com> wrote:
> > >
> > > Hi Marc,
> > >
> > > Thanks for your feedback.
> > >
> > > > From: Marc Zyngier <maz@kernel.org>
> > > > Sent: Monday, September 30, 2024 4:50 PM
> > > > To: Fabrizio Castro <fabrizio.castro.jz@renesas.com>
> > > > Subject: Re: [PATCH] irqchip/renesas-rzg2l: Fix missing put_device
> > > >
> > > > On Mon, 30 Sep 2024 15:55:39 +0100,
> > > > Fabrizio Castro <fabrizio.castro.jz@renesas.com> wrote:
> > > > >
> > > > > rzg2l_irqc_common_init calls of_find_device_by_node, but the
> > > > > corresponding put_device call is missing.
> > > > >
> > > > > Make sure we call put_device both when failing and when succeeding.
> > > >
> > > > What sort of lifetime are you trying to enforce?
> > >
> > > Function rzg2l_irqc_common_init uses pdev->dev until its very end.
> > > My understanding is that we should decrement the reference counter
> > > once we are fully done with it. Is my understanding correct?
> >
> > "done with it" is what scares me. Specially when I see code like this:
> >
> > rzg2l_irqc_data = devm_kzalloc(&pdev->dev, sizeof(*rzg2l_irqc_data), GFP_KERNEL);
> > if (!rzg2l_irqc_data)
> > return -ENOMEM;
> >
> > rzg2l_irqc_data->irqchip = irq_chip;
> >
> > rzg2l_irqc_data->base = devm_of_iomap(&pdev->dev, pdev->dev.of_node, 0, NULL);
> > if (IS_ERR(rzg2l_irqc_data->base))
> > return PTR_ERR(rzg2l_irqc_data->base);
> >
> > If you drop the reference on the device, you are allowing it to be
> > removed, and everything the driver cares about to disappear behind
> > its back.
>
> Thanks for the explanation. I think this means that we don't need to
> put the device on the successful path, but we still need to put the
> device on the error path.
That I would agree.
> If I take out the put_device for the successful path, and I run make
> coccicheck, I get the below:
> drivers/irqchip/irq-renesas-rzg2l.c:601:1-7: ERROR: missing
> put_device; call of_find_device_by_node on line 538, but without a
> corresponding object release within this function.
>
> Can I just ignore it?
My general approach is that these scripts are not a substitute for
reasoning, and in this instance, the advise seems pretty misplaced.
I would suggest you add a comment to keep the next script kiddie at
bay.
M.
--
Without deviation from the norm, progress is not possible.
prev parent reply other threads:[~2024-10-06 15:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-30 14:55 [PATCH] irqchip/renesas-rzg2l: Fix missing put_device Fabrizio Castro
2024-09-30 15:50 ` Marc Zyngier
2024-09-30 16:36 ` Fabrizio Castro
2024-09-30 19:14 ` Marc Zyngier
2024-10-01 11:54 ` Fabrizio Castro
2024-10-06 15:53 ` Marc Zyngier [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=861q0t6xdl.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=Chris.Paterson2@renesas.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=fabrizio.castro.jz@renesas.com \
--cc=geert+renesas@glider.be \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.