From 405544eae56e06845e026b73527016db1638ff45 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sun, 27 Sep 2020 19:45:50 -0400 Subject: [PATCH] pan/bi: Fix memory corruption in scheduler If empty the last will be bogus, I think. Missing Rust hard right around now. Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/bifrost/bi_schedule.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/panfrost/bifrost/bi_schedule.c b/src/panfrost/bifrost/bi_schedule.c index 2ff1d50..a336e5e 100644 --- a/src/panfrost/bifrost/bi_schedule.c +++ b/src/panfrost/bifrost/bi_schedule.c @@ -241,10 +241,11 @@ bi_schedule(bi_context *ctx) /* Back-to-back bit affects only the last clause of a block, * the rest are implicitly true */ - bi_clause *last_clause = list_last_entry(&bblock->clauses, bi_clause, link); - if (last_clause) + if (!list_is_empty(&bblock->clauses)) { + bi_clause *last_clause = list_last_entry(&bblock->clauses, bi_clause, link); last_clause->back_to_back = bi_back_to_back(bblock); + } bblock->scheduled = true; } -- 2.7.4