From ba0306c8135217ffed383245680f125cbe3b1106 Mon Sep 17 00:00:00 2001 From: mataotao Date: Tue, 10 Mar 2026 11:38:45 +0800 Subject: [PATCH] avocado/utils/disk: fix list aliasing in get_all_disk_paths The assignment disk_list = abs_path = [] creates a single list referenced by both names, causing entries to accumulate across loop iterations and duplicate on each extend call. Initialise disk_list separately and reset abs_path inside the loop. Signed-off-by: Poppt-mt 935295021@qq.com --- avocado/utils/disk.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/avocado/utils/disk.py b/avocado/utils/disk.py index 71b23d65e3..6cc520410e 100644 --- a/avocado/utils/disk.py +++ b/avocado/utils/disk.py @@ -149,7 +149,7 @@ def get_all_disk_paths(): :returns: a list of all disk path names :rtype: list of str """ - disk_list = abs_path = [] + disk_list = [] for path in [ "/dev", "/dev/mapper", @@ -160,6 +160,7 @@ def get_all_disk_paths(): "/dev/disk/by-partlabel", ]: if os.path.exists(path): + abs_path = [] for device in os.listdir(path): abs_path.append(os.path.join(path, device)) disk_list.extend(abs_path)