Do not add elements to purge list which are not in the kernel, otherwise, bogus ENOENT is reported. Fixes: 3e8d934e4f722 ("intervals: support to partial deletion with automerge") Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> --- v2: no changes src/intervals.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/intervals.c b/src/intervals.c index a8fada9ba079..590a2967c0f3 100644 --- a/src/intervals.c +++ b/src/intervals.c @@ -329,8 +329,10 @@ static void split_range(struct set *set, struct expr *prev, struct expr *i, { struct expr *clone; - clone = expr_clone(prev); - list_move_tail(&clone->list, &purge->expressions); + if (prev->flags & EXPR_F_KERNEL) { + clone = expr_clone(prev); + list_move_tail(&clone->list, &purge->expressions); + } prev->flags &= ~EXPR_F_KERNEL; clone = expr_clone(prev); @@ -413,7 +415,9 @@ static int setelem_delete(struct list_head *msgs, struct set *set, if (mpz_cmp(prev_range.low, range.low) == 0 && mpz_cmp(prev_range.high, range.high) == 0) { if (i->flags & EXPR_F_REMOVE) { - list_move_tail(&prev->list, &purge->expressions); + if (prev->flags & EXPR_F_KERNEL) + list_move_tail(&prev->list, &purge->expressions); + list_del(&i->list); expr_free(i); } -- 2.30.2