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> --- super-intel.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/super-intel.c b/super-intel.c index ef21ffba..98fb63d5 100644 --- a/super-intel.c +++ b/super-intel.c @@ -700,8 +700,11 @@ static struct sys_dev* find_disk_attached_hba(int fd, const char *devname) return 0; for (elem = list; elem; elem = elem->next) - if (path_attached_to_hba(disk_path, elem->path)) + if (path_attached_to_hba(disk_path, elem->path)) { + if (disk_path != devname) + free(disk_path); return elem; + } if (disk_path != devname) free(disk_path); -- 2.27.0