From b15a58e688689b75563eb2936f7e19c949bca699 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 23 Jun 2023 13:27:42 -0700 Subject: til_fb: prevent 0-height slices til_fb_fragment_slice_single() and indirectly til_fragmenter_slice_per_cpu() could get into infinite loops when slicing small fragments into many slices. This became more likely with commit a2f7397 which increased per_cpu slice counts by 16X, which is how I tripped over it running rtv. A checkers,size=8,fill_module=moire sent things spinning... This commit prevents it in the obvious manner. --- src/til_fb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/til_fb.c b/src/til_fb.c index 011e9ce..a6bdf69 100644 --- a/src/til_fb.c +++ b/src/til_fb.c @@ -574,7 +574,7 @@ void * til_fb_context(til_fb_t *fb) /* helpers for fragmenting incrementally */ int til_fb_fragment_slice_single(const til_fb_fragment_t *fragment, unsigned n_fragments, unsigned number, til_fb_fragment_t *res_fragment) { - unsigned slice = fragment->height / n_fragments; + unsigned slice = MAX(fragment->height / n_fragments, 1); unsigned yoff = slice * number; assert(fragment); -- cgit v1.2.3