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: <a1588e43-2cb9-4356-ac73-b09593d0218c@ideasonboard.com>
Date: Mon, 14 Oct 2024 14:31:56 +0530
From: Umang Jain <umang.jain@...asonboard.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
 Broadcom internal kernel review list <bcm-kernel-feedback-list@...adcom.com>
Cc: linux-rpi-kernel@...ts.infradead.org,
 linux-arm-kernel@...ts.infradead.org, linux-staging@...ts.linux.dev,
 linux-kernel@...r.kernel.org,
 Kieran Bingham <kieran.bingham@...asonboard.com>,
 Dan Carpenter <dan.carpenter@...aro.org>,
 Laurent Pinchart <laurent.pinchart@...asonboard.com>,
 kernel-list@...pberrypi.com, Stefan Wahren <wahrenst@....net>,
 Javier Carrasco <javier.carrasco.cruz@...il.com>, stable@...r.kernel.org
Subject: Re: [PATCH] staging: vchiq_arm: Utilize devm_kzalloc in the probe()
 function

Hi all,

Please ignore this patch, it was a wrong-send (older version)

On 14/10/24 1:29 pm, Umang Jain wrote:
> The two resources, 'mgmt' and 'platform_state' are currently allocated
> dynamically using kzalloc(). Unfortunately, both are subject to memory
> leaks in the error handling paths of the probe() function.
>
> To address this issue, use device resource management helper devm_kzalloc()
> for proper cleanup during allocation.
>
> Cc: stable@...r.kernel.org
> Fixes: 1c9e16b73166 ("staging: vc04_services: vchiq_arm: Split driver static and runtime data")
> Signed-off-by: Umang Jain <umang.jain@...asonboard.com>
> ---
>   .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c   | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> index 29e78700463f..373cfdd5b020 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
> @@ -285,7 +285,7 @@ vchiq_platform_init_state(struct vchiq_state *state)
>   {
>   	struct vchiq_arm_state *platform_state;
>   
> -	platform_state = kzalloc(sizeof(*platform_state), GFP_KERNEL);
> +	platform_state = devm_kzalloc(state->dev, sizeof(*platform_state), GFP_KERNEL);
>   	if (!platform_state)
>   		return -ENOMEM;
>   
> @@ -1344,7 +1344,7 @@ static int vchiq_probe(struct platform_device *pdev)
>   		return -ENOENT;
>   	}
>   
> -	mgmt = kzalloc(sizeof(*mgmt), GFP_KERNEL);
> +	mgmt = devm_kzalloc(&pdev->dev, sizeof(*mgmt), GFP_KERNEL);
>   	if (!mgmt)
>   		return -ENOMEM;
>   
> @@ -1402,8 +1402,6 @@ static void vchiq_remove(struct platform_device *pdev)
>   
>   	arm_state = vchiq_platform_get_arm_state(&mgmt->state);
>   	kthread_stop(arm_state->ka_thread);
> -
> -	kfree(mgmt);
>   }
>   
>   static struct platform_driver vchiq_driver = {


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ