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: <Z1_2sugsla44LgIz@cassiopeiae>
Date: Mon, 16 Dec 2024 10:45:22 +0100
From: Danilo Krummrich <dakr@...hat.com>
To: Zhanxin Qi <zhanxin@...china.com>
Cc: kherbst@...hat.com, lyude@...hat.com, airlied@...il.com,
	simona@...ll.ch, dri-devel@...ts.freedesktop.org,
	nouveau@...ts.freedesktop.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drm/nouveau: Fix memory leak in nvbios_iccsense_parse

Thanks for the patch, some notes below.

On Mon, Dec 16, 2024 at 09:52:46AM +0800, Zhanxin Qi wrote:
> The nvbios_iccsense_parse function allocates memory for sensor data
> but fails to free it when the function exits, leading to a memory
> leak. Add proper cleanup to free the allocated memory.
> 
> Signed-off-by: Zhanxin Qi <zhanxin@...china.com>

Please also add a "Fixes:" tag and "Cc: stable@...r.kernel.org" for this.

> ---
>  drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> index 8f0ccd3664eb..502608d575f7 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/iccsense/base.c
> @@ -291,6 +291,9 @@ nvkm_iccsense_oneinit(struct nvkm_subdev *subdev)
>  			list_add_tail(&rail->head, &iccsense->rails);
>  		}
>  	}
> +
> +	kfree(stbl.rail);

I think it's a bit subtile why this is needed here; better add a new inline
function (nvbios_iccsense_cleanup()) to include/nvkm/subdev/bios/iccsense.h that
frees the memory and call this one instead.

While at it, you may also want to send a separate patch, adding a brief comment
to nvbios_iccsense_parse() which notes, that after a successful call to
nvbios_iccsense_parse() it must be cleaned up with nvbios_iccsense_cleanup().

> +
>  	return 0;
>  }
>  
> -- 
> 2.30.2
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ