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: <663a37fe-ffc4-4826-b8ba-bcefdb0e7992@web.de>
Date: Fri, 11 Oct 2024 20:48:18 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: Fabrizio Castro <fabrizio.castro.jz@...esas.com>,
 linux-renesas-soc@...r.kernel.org,
 Geert Uytterhoeven <geert+renesas@...der.be>,
 Thomas Gleixner <tglx@...utronix.de>
Cc: LKML <linux-kernel@...r.kernel.org>, kernel-janitors@...r.kernel.org,
 Biju Das <biju.das.jz@...renesas.com>,
 Chris Paterson <Chris.Paterson2@...esas.com>,
 Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>,
 Marc Zyngier <maz@...nel.org>
Subject: Re: [PATCH v4] 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.

How do you think about to append parentheses to function names
(so that they can be distinguished a bit easier from other identifiers)?


> Make use of the cleanup interfaces from cleanup.h to call into
> __free_put_device (which in turn calls into put_device) when

Can it help to influence the understanding of this programming
interface by mentioning the usage of a special attribute?


> leaving function rzg2l_irqc_common_init and variable "dev" goes
> out of scope.
>
> Mind that we don't want to "put" "dev" when rzg2l_irqc_common_init
> completes successfully, therefore assign NULL to "dev" to prevent
> __free_put_device from calling into put_device within the successful
> path.

Will further software design options become applicable here?

Can any pointer type be used for the return value
(instead of the data type “int”)?


> "make coccicheck" will still complain about missing put_device calls,
> but those are false positives now.

Would you like to discuss any adjustment possibilities for this
development tool?


…
> +++ b/drivers/irqchip/irq-renesas-rzg2l.c
> @@ -8,6 +8,7 @@
>   */
>
>  #include <linux/bitfield.h>
> +#include <linux/cleanup.h>
…

This header file would usually be included by an other inclusion statement already,
wouldn't it?
https://elixir.bootlin.com/linux/v6.12-rc2/source/include/linux/device.h#L33


…
> @@ -530,12 +531,12 @@ static int rzg2l_irqc_parse_interrupts(struct rzg2l_irqc_priv *priv,
>  static int rzg2l_irqc_common_init(struct device_node *node, struct device_node *parent,
>  				  const struct irq_chip *irq_chip)
>  {
> +	struct platform_device *pdev = of_find_device_by_node(node);
> +	struct device *dev __free(put_device) = pdev ? &pdev->dev : NULL;
>  	struct irq_domain *irq_domain, *parent_domain;
> -	struct platform_device *pdev;
>  	struct reset_control *resetn;
>  	int ret;
>
> -	pdev = of_find_device_by_node(node);
>  	if (!pdev)
>  		return -ENODEV;
…

Would you dare to reduce the scopes for any local variables here?
https://refactoring.com/catalog/reduceScopeOfVariable.html

Regards,
Markus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ