From e8ff6013dc393a00c1630795d72ec23be5319ac8 Mon Sep 17 00:00:00 2001 From: Kees Cook <keescook@chromium.org> Date: Mon, 23 Apr 2018 08:20:34 +1000 Subject: [PATCH] exofs-avoid-vla-in-structures-v2 - use DRY for easier to read stripe updates (ndesaulniers) - add const to unchanging variable (ndesaulniers) - update references with message-id URLs - add Reviewed-by Link: http://lkml.kernel.org/r/20180418163546.GA45794@beast Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Cc: Boaz Harrosh <ooo@electrozaur.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au> --- fs/exofs/ore_raid.c | 12 ++++++------ fs/exofs/super.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/exofs/ore_raid.c b/fs/exofs/ore_raid.c index 659129d5e9f7..199590f36203 100644 --- a/fs/exofs/ore_raid.c +++ b/fs/exofs/ore_raid.c @@ -139,6 +139,8 @@ static int _sp2d_alloc(unsigned pages_in_unit, unsigned group_width, /* Allocate additionally needed a1pa items in PAGE_SIZE chunks. */ for (i = 0; i < pages_in_unit; ++i) { + struct __1_page_stripe *stripe = &sp2d->_1p_stripes[i]; + if (unlikely(__a1pa >= __a1pa_end)) { num_a1pa = min_t(unsigned, PAGE_SIZE / sizeof__a1pa, pages_in_unit - i); @@ -152,7 +154,7 @@ static int _sp2d_alloc(unsigned pages_in_unit, unsigned group_width, } __a1pa_end = __a1pa + alloc_size; /* First *pages is marked for kfree of the buffer */ - sp2d->_1p_stripes[i].alloc = true; + stripe->alloc = true; } /* @@ -160,11 +162,9 @@ static int _sp2d_alloc(unsigned pages_in_unit, unsigned group_width, * it which was either part of the original PAGE_SIZE * allocation or the subsequent allocation in this loop. */ - sp2d->_1p_stripes[i].pages = (void *)__a1pa; - sp2d->_1p_stripes[i].scribble = - sp2d->_1p_stripes[i].pages + group_width; - sp2d->_1p_stripes[i].page_is_read = - (char *)(sp2d->_1p_stripes[i].scribble + group_width); + stripe->pages = (void *)__a1pa; + stripe->scribble = stripe->pages + group_width; + stripe->page_is_read = (char *)stripe->scribble + group_width; __a1pa += sizeof__a1pa; } diff --git a/fs/exofs/super.c b/fs/exofs/super.c index f3c29e9326f1..fabd15e482be 100644 --- a/fs/exofs/super.c +++ b/fs/exofs/super.c @@ -552,7 +552,7 @@ static int __alloc_dev_table(struct exofs_sb_info *sbi, unsigned numdevs, /* Twice bigger table: See exofs_init_comps() and comment at * exofs_read_lookup_dev_table() */ - size_t numores = numdevs * 2 - 1; + const size_t numores = numdevs * 2 - 1; struct exofs_dev *eds; unsigned i; -- GitLab