Skip to content

Commit 590347e

Browse files
arndbsnitm
authored andcommitted
dm bufio: avoid false-positive Wmaybe-uninitialized warning
gcc-6.3 and earlier show a new warning after a seemingly unrelated change to the arm64 PAGE_KERNEL definition: In file included from drivers/md/dm-bufio.c:14:0: drivers/md/dm-bufio.c: In function 'alloc_buffer': include/linux/sched/mm.h:182:56: warning: 'noio_flag' may be used uninitialized in this function [-Wmaybe-uninitialized] current->flags = (current->flags & ~PF_MEMALLOC_NOIO) | flags; ^ The same warning happened earlier on linux-3.18 for MIPS and I did a workaround for that, but now it's come back. gcc-7 and newer are apparently smart enough to figure this out, and other architectures don't show it, so the best I could come up with is to rework the caller slightly in a way that makes it obvious enough to all arm64 compilers what is happening here. Fixes: 41acec6 ("arm64: kpti: Make use of nG dependent on arm64_kernel_unmapped_at_el0()") Link: https://patchwork.kernel.org/patch/9692829/ Cc: [email protected] Signed-off-by: Arnd Bergmann <[email protected]> [snitzer: moved declarations inside conditional, altered vmalloc return] Signed-off-by: Mike Snitzer <[email protected]>
1 parent 661e50b commit 590347e

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

drivers/md/dm-bufio.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,6 @@ static void __cache_size_refresh(void)
386386
static void *alloc_buffer_data(struct dm_bufio_client *c, gfp_t gfp_mask,
387387
enum data_mode *data_mode)
388388
{
389-
unsigned noio_flag;
390-
void *ptr;
391-
392389
if (c->block_size <= DM_BUFIO_BLOCK_SIZE_SLAB_LIMIT) {
393390
*data_mode = DATA_MODE_SLAB;
394391
return kmem_cache_alloc(DM_BUFIO_CACHE(c), gfp_mask);
@@ -412,16 +409,15 @@ static void *alloc_buffer_data(struct dm_bufio_client *c, gfp_t gfp_mask,
412409
* all allocations done by this process (including pagetables) are done
413410
* as if GFP_NOIO was specified.
414411
*/
412+
if (gfp_mask & __GFP_NORETRY) {
413+
unsigned noio_flag = memalloc_noio_save();
414+
void *ptr = __vmalloc(c->block_size, gfp_mask, PAGE_KERNEL);
415415

416-
if (gfp_mask & __GFP_NORETRY)
417-
noio_flag = memalloc_noio_save();
418-
419-
ptr = __vmalloc(c->block_size, gfp_mask, PAGE_KERNEL);
420-
421-
if (gfp_mask & __GFP_NORETRY)
422416
memalloc_noio_restore(noio_flag);
417+
return ptr;
418+
}
423419

424-
return ptr;
420+
return __vmalloc(c->block_size, gfp_mask, PAGE_KERNEL);
425421
}
426422

427423
/*

0 commit comments

Comments
 (0)