Re: [PATCH v1] x86/mm/pat: (un)track_pfn_copy() fix + improvements
From: Dan Carpenter
Date: Mon Apr 07 2025 - 15:08:07 EST
On Mon, Apr 07, 2025 at 06:50:43PM +0200, Ingo Molnar wrote:
> > diff --git a/mm/memory.c b/mm/memory.c
> > index 2d8c265fc7d60..1a35165622e1c 100644
> > --- a/mm/memory.c
> > +++ b/mm/memory.c
> > @@ -1361,7 +1361,7 @@ copy_page_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma)
> > struct mm_struct *dst_mm = dst_vma->vm_mm;
> > struct mm_struct *src_mm = src_vma->vm_mm;
> > struct mmu_notifier_range range;
> > - unsigned long next, pfn;
> > + unsigned long next, pfn = 0;
>
> Ack.
>
> I hate it how uninitialized variables are even a thing in C, and why
> there's no compiler switch to turn it off for the kernel. (At least for
> non-struct variables. Even for structs I would zero-initialize and
> *maybe* allow a non-initialized opt-in for cases where it matters. It
> matters in very few cases in praxis. And don't get me started about the
> stupidity that is to not initialize holes in struct members ...)
Everyone sane uses CONFIG_INIT_STACK_ALL_ZERO these days.
regards,
dan carpenter