* [PATCH next] x86/mm: Fix uninitialized variable in register_page_bootmem_memmap()
@ 2025-02-12 15:21 Dan Carpenter
2025-02-12 17:59 ` Frank van der Linden
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2025-02-12 15:21 UTC (permalink / raw)
To: Frank van der Linden
Cc: Dave Hansen, Andy Lutomirski, Peter Zijlstra, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, x86, H. Peter Anvin, Andrew Morton,
linux-kernel, kernel-janitors
Smatch complains that "next" could be uninitialized. The "next"
assignment was accidentally left out when we moved these lines to earlier
in the function.
Fixes: bdadaec1526d ("x86/mm: make register_page_bootmem_memmap handle PTE mappings")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
This goes through the -mm tree.
arch/x86/mm/init_64.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index e7572af639a4..6e8e4ef5312a 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1600,8 +1600,10 @@ void register_page_bootmem_memmap(unsigned long section_nr,
get_page_bootmem(section_nr, pud_page(*pud), MIX_SECTION_INFO);
pmd = pmd_offset(pud, addr);
- if (pmd_none(*pmd))
+ if (pmd_none(*pmd)) {
+ next = (addr + PAGE_SIZE) & PAGE_MASK;
continue;
+ }
if (!boot_cpu_has(X86_FEATURE_PSE) || !pmd_leaf(*pmd)) {
next = (addr + PAGE_SIZE) & PAGE_MASK;
--
2.47.2
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH next] x86/mm: Fix uninitialized variable in register_page_bootmem_memmap()
2025-02-12 15:21 [PATCH next] x86/mm: Fix uninitialized variable in register_page_bootmem_memmap() Dan Carpenter
@ 2025-02-12 17:59 ` Frank van der Linden
2025-02-12 18:13 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Frank van der Linden @ 2025-02-12 17:59 UTC (permalink / raw)
To: Dan Carpenter
Cc: Dave Hansen, Andy Lutomirski, Peter Zijlstra, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, x86, H. Peter Anvin, Andrew Morton,
linux-kernel, kernel-janitors
On Wed, Feb 12, 2025 at 7:21 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> Smatch complains that "next" could be uninitialized. The "next"
> assignment was accidentally left out when we moved these lines to earlier
> in the function.
>
> Fixes: bdadaec1526d ("x86/mm: make register_page_bootmem_memmap handle PTE mappings")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> This goes through the -mm tree.
>
> arch/x86/mm/init_64.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> index e7572af639a4..6e8e4ef5312a 100644
> --- a/arch/x86/mm/init_64.c
> +++ b/arch/x86/mm/init_64.c
> @@ -1600,8 +1600,10 @@ void register_page_bootmem_memmap(unsigned long section_nr,
> get_page_bootmem(section_nr, pud_page(*pud), MIX_SECTION_INFO);
>
> pmd = pmd_offset(pud, addr);
> - if (pmd_none(*pmd))
> + if (pmd_none(*pmd)) {
> + next = (addr + PAGE_SIZE) & PAGE_MASK;
> continue;
> + }
>
> if (!boot_cpu_has(X86_FEATURE_PSE) || !pmd_leaf(*pmd)) {
> next = (addr + PAGE_SIZE) & PAGE_MASK;
> --
> 2.47.2
>
Thanks for catching that Dan. I believe Andrew took the series out of
mm-unstable because of some conflicts, and asked me to do a v4 for
mm-unstable. Would you mind if I just folded your change in to the v4
series?
As an aside, it seems that this function could use some cleanup. It
seems wrong to only advance by PAGE_SIZE when you encounter an
unpopulated p4d/pgd/pud/pmd. It should advance to the end of that
p4d/pgd/pud/pmd. I suppose that case won't happen in practice, though,
which is also why this hasn't caused me any issues.
- Frank
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH next] x86/mm: Fix uninitialized variable in register_page_bootmem_memmap()
2025-02-12 17:59 ` Frank van der Linden
@ 2025-02-12 18:13 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-02-12 18:13 UTC (permalink / raw)
To: Frank van der Linden
Cc: Dave Hansen, Andy Lutomirski, Peter Zijlstra, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, x86, H. Peter Anvin, Andrew Morton,
linux-kernel, kernel-janitors
On Wed, Feb 12, 2025 at 09:59:54AM -0800, Frank van der Linden wrote:
> On Wed, Feb 12, 2025 at 7:21 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
> >
> > Smatch complains that "next" could be uninitialized. The "next"
> > assignment was accidentally left out when we moved these lines to earlier
> > in the function.
> >
> > Fixes: bdadaec1526d ("x86/mm: make register_page_bootmem_memmap handle PTE mappings")
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> > This goes through the -mm tree.
> >
> > arch/x86/mm/init_64.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> > index e7572af639a4..6e8e4ef5312a 100644
> > --- a/arch/x86/mm/init_64.c
> > +++ b/arch/x86/mm/init_64.c
> > @@ -1600,8 +1600,10 @@ void register_page_bootmem_memmap(unsigned long section_nr,
> > get_page_bootmem(section_nr, pud_page(*pud), MIX_SECTION_INFO);
> >
> > pmd = pmd_offset(pud, addr);
> > - if (pmd_none(*pmd))
> > + if (pmd_none(*pmd)) {
> > + next = (addr + PAGE_SIZE) & PAGE_MASK;
> > continue;
> > + }
> >
> > if (!boot_cpu_has(X86_FEATURE_PSE) || !pmd_leaf(*pmd)) {
> > next = (addr + PAGE_SIZE) & PAGE_MASK;
> > --
> > 2.47.2
> >
>
> Thanks for catching that Dan. I believe Andrew took the series out of
> mm-unstable because of some conflicts, and asked me to do a v4 for
> mm-unstable. Would you mind if I just folded your change in to the v4
> series?
Yeah, no problem. -mm patches are always folded.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-02-12 18:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-12 15:21 [PATCH next] x86/mm: Fix uninitialized variable in register_page_bootmem_memmap() Dan Carpenter
2025-02-12 17:59 ` Frank van der Linden
2025-02-12 18:13 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®