Re: [PATCH 4/5 v2] find_disk_attached_hba: fix memleak

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

 




> 2022年8月2日 10:16,Wu Guanghao <wuguanghao3@xxxxxxxxxx> 写道:
> 
> If disk_path = diskfd_to_devpath(), we need free(disk_path) before
> return, otherwise there will be a memory leak
> 
> Signed-off-by: Wu Guanghao <wuguanghao3@xxxxxxxxxx>
> Reviewed-by: Mariusz Tkaczyk <mariusz.tkaczyk@xxxxxxxxxxxxxxx>

Acked-by: Coly Li <colyli@xxxxxxx>

Thanks.

Coly Li

> ---
> super-intel.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/super-intel.c b/super-intel.c
> index ddbdd3e1..2a4019e7 100644
> --- a/super-intel.c
> +++ b/super-intel.c
> @@ -713,12 +713,12 @@ static struct sys_dev* find_disk_attached_hba(int fd, const char *devname)
> 
>        for (elem = list; elem; elem = elem->next)
>                if (path_attached_to_hba(disk_path, elem->path))
> -                       return elem;
> +                       break;
> 
>        if (disk_path != devname)
>                free(disk_path);
> 
> -       return NULL;
> +       return elem;
> }
> 
> static int find_intel_hba_capability(int fd, struct intel_super *super,
> --
> 2.27.0





[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux