Re: [PATCH v1] x86/mm/pat: (un)track_pfn_copy() fix + improvements
From: Ingo Molnar
Date: Sun Apr 06 2025 - 13:28:41 EST
* David Hildenbrand <david@xxxxxxxxxx> wrote:
> We got a late smatch warning and some additional review feedback.
>
> smatch warnings:
> mm/memory.c:1428 copy_page_range() error: uninitialized symbol 'pfn'.
> - if (!(src_vma->vm_flags & VM_PAT))
> + if (!(src_vma->vm_flags & VM_PAT)) {
> + *pfn = 0;
> return 0;
> + }
> static inline int track_pfn_copy(struct vm_area_struct *dst_vma,
> struct vm_area_struct *src_vma, unsigned long *pfn)
> {
> + *pfn = 0;
> return 0;
> }
That's way too ugly. There's nothing wrong with not touching 'pfn' in
the error path: in fact it's pretty standard API where output pointers
may not get set on errors.
If Smatch has a problem with it, Smatch should be fixed, or the false
positive warning should be worked around by initializing 'pfn' in the
callers.
Thanks,
Ingo