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] [day] [month] [year] [list]
Message-ID: <CAAQKjZO0VhkpsM4L+C97QcCAjF_b99zp2W25n+swLP6K1OUpww@mail.gmail.com>
Date: Thu, 25 Apr 2024 10:47:59 +0900
From: Inki Dae <daeinki@...il.com>
To: Shivani Gupta <shivani07g@...il.com>
Cc: Seung-Woo Kim <sw0312.kim@...sung.com>, Kyungmin Park <kyungmin.park@...sung.com>, 
	David Airlie <airlied@...il.com>, Daniel Vetter <daniel@...ll.ch>, 
	Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>, Alim Akhtar <alim.akhtar@...sung.com>, 
	Julia Lawall <julia.lawall@...ia.fr>, Shuah Khan <skhan@...uxfoundation.org>, 
	Javier Carrasco <javier.carrasco.cruz@...il.com>, dri-devel@...ts.freedesktop.org, 
	linux-arm-kernel@...ts.infradead.org, linux-samsung-soc@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] gpu: drm: exynos: hdmi: eliminate uses of of_node_put()

Good cleanup. Applied. :)

Thanks,
Inki Dae

2024년 4월 15일 (월) 오전 9:40, Shivani Gupta <shivani07g@...il.com>님이 작성:
>
> Utilize the __free() cleanup handler within the hdmi_get_phy_io function
> to automatically release the device node when it is out of scope.
> This eliminates the manual invocation of of_node_put(), reducing the
> potential for memory leaks.
>
> The modification requires initializing the device node at the beginning
> of the function, ensuring that the automatic cleanup is safely executed.
>
> Consequently, this removes the need for error cleanup paths that utilize
> goto statements and the jump to out is no longer necessary.
>
> Suggested-by: Julia Lawall <julia.lawall@...ia.fr>
> Signed-off-by: Shivani Gupta <shivani07g@...il.com>
> ---
>  drivers/gpu/drm/exynos/exynos_hdmi.c | 15 +++++----------
>  1 file changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
> index b1d02dec3774..a741fd949482 100644
> --- a/drivers/gpu/drm/exynos/exynos_hdmi.c
> +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
> @@ -1919,10 +1919,9 @@ static int hdmi_get_ddc_adapter(struct hdmi_context *hdata)
>  static int hdmi_get_phy_io(struct hdmi_context *hdata)
>  {
>         const char *compatible_str = "samsung,exynos4212-hdmiphy";
> -       struct device_node *np;
> -       int ret = 0;
> +       struct device_node *np __free(device_node) =
> +               of_find_compatible_node(NULL, NULL, compatible_str);
>
> -       np = of_find_compatible_node(NULL, NULL, compatible_str);
>         if (!np) {
>                 np = of_parse_phandle(hdata->dev->of_node, "phy", 0);
>                 if (!np) {
> @@ -1937,21 +1936,17 @@ static int hdmi_get_phy_io(struct hdmi_context *hdata)
>                 if (!hdata->regs_hdmiphy) {
>                         DRM_DEV_ERROR(hdata->dev,
>                                       "failed to ioremap hdmi phy\n");
> -                       ret = -ENOMEM;
> -                       goto out;
> +                       return -ENOMEM;
>                 }
>         } else {
>                 hdata->hdmiphy_port = of_find_i2c_device_by_node(np);
>                 if (!hdata->hdmiphy_port) {
>                         DRM_INFO("Failed to get hdmi phy i2c client\n");
> -                       ret = -EPROBE_DEFER;
> -                       goto out;
> +                       return -EPROBE_DEFER;
>                 }
>         }
>
> -out:
> -       of_node_put(np);
> -       return ret;
> +       return 0;
>  }
>
>  static int hdmi_probe(struct platform_device *pdev)
> --
> 2.34.1
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ