lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
 <TYCPR01MB120935A52A777BF62344B05C3C2772@TYCPR01MB12093.jpnprd01.prod.outlook.com>
Date: Tue, 1 Oct 2024 11:54:30 +0000
From: Fabrizio Castro <fabrizio.castro.jz@...esas.com>
To: Marc Zyngier <maz@...nel.org>
CC: Thomas Gleixner <tglx@...utronix.de>, Geert Uytterhoeven
	<geert+renesas@...der.be>, Prabhakar Mahadev Lad
	<prabhakar.mahadev-lad.rj@...renesas.com>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>, Chris Paterson <Chris.Paterson2@...esas.com>,
	Biju Das <biju.das.jz@...renesas.com>, "linux-renesas-soc@...r.kernel.org"
	<linux-renesas-soc@...r.kernel.org>
Subject: RE: [PATCH] irqchip/renesas-rzg2l: Fix missing put_device

Hi Marc,

thank you for your reply.

> From: Marc Zyngier <maz@...nel.org>
> Sent: Monday, September 30, 2024 8:15 PM
> To: Fabrizio Castro <fabrizio.castro.jz@...esas.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@...esas.com> wrote:
> >
> > Hi Marc,
> >
> > Thanks for your feedback.
> >
> > > From: Marc Zyngier <maz@...nel.org>
> > > Sent: Monday, September 30, 2024 4:50 PM
> > > To: Fabrizio Castro <fabrizio.castro.jz@...esas.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@...esas.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.

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?

Thanks!

Kind regards,
Fab

> 
> I can't really see how this is safe, because in general, removing an interrupt controller driver from
> the system is a pretty bad idea, and I'm worried that's you are implicitly enabling.
> 
> 	M.
> 
> --
> Without deviation from the norm, progress is not possible.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ