Re: [PATCH] drm/nouveau: Fix memory leak in nvbios_iccsense_parse

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>

Please also add a "Fixes:" tag and "Cc: stable@xxxxxxxxxxxxxxx" 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
> 




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux