summaryrefslogtreecommitdiff
path: root/src/til_fb.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2023-06-23 13:27:42 -0700
committerVito Caputo <vcaputo@pengaru.com>2023-06-23 13:27:42 -0700
commitb15a58e688689b75563eb2936f7e19c949bca699 (patch)
treec8cf608f816d1007eb3e60f1d79835bd4e3cebbf /src/til_fb.c
parentf8606bd69655b5bfce053d80d6b9f7ead6e7f03f (diff)
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.
Diffstat (limited to 'src/til_fb.c')
-rw-r--r--src/til_fb.c2
1 files changed, 1 insertions, 1 deletions
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);
© All Rights Reserved