From: Karel Zak Date: Mon, 25 Sep 2023 11:19:49 +0000 (+0200) Subject: lsblk: fix in-tree filtering X-Git-Tag: v2.40-rc1~151^2~57 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c4b7821456f1645f4caf015c2e82a37af5f6bdfa;p=thirdparty%2Futil-linux.git lsblk: fix in-tree filtering The function device_to_scols() is used recursively (for children). It's impossible leave the function on filter status=false, it's necessary to continue in the tree. Signed-off-by: Karel Zak --- diff --git a/misc-utils/lsblk.c b/misc-utils/lsblk.c index 6050cbf40a..eb758b170b 100644 --- a/misc-utils/lsblk.c +++ b/misc-utils/lsblk.c @@ -1317,18 +1317,18 @@ static void device_to_scols( if (x) scols_line_remove_child(x, ln); scols_table_remove_line(tab, ln); - goto done; + ln = NULL; } } /* read column specific data and set it to smartcols table line */ - for (i = 0; i < ncolumns; i++) { + for (i = 0; ln && i < ncolumns; i++) { if (scols_line_is_filled(ln, i)) continue; device_fill_scols_cell(dev, parent, ln, i); } - if (link_group) { + if (ln && link_group) { struct lsblk_device *p; struct libscols_line *gr = parent_line; @@ -1371,7 +1371,6 @@ static void device_to_scols( scols_line_set_color(ln, lsblk->hlighter_seq); } -done: /* Let's be careful with number of open files */ ul_path_close_dirfd(dev->sysfs); }