Re: [PATCH] mm/sparse:avoid null pointer access in memory_present()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 17 Jun 2023 14:40:36 +1000 Liam Ni <zhiguangni01@xxxxxxxxx> wrote:

> __nr_to_section() may return a null pointer,
> before accessing the member variable section_mem_map,
> we should first determine whether it is a null pointer.
> 
> ...
>
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -258,7 +258,7 @@ static void __init memory_present(int nid, unsigned long start, unsigned long en
>  		set_section_nid(section, nid);
>  
>  		ms = __nr_to_section(section);
> -		if (!ms->section_mem_map) {
> +		if (ms && !ms->section_mem_map) {
>  			ms->section_mem_map = sparse_encode_early_nid(nid) |
>  							SECTION_IS_ONLINE;
>  			__section_mark_present(ms, section);

I'm suspecting that if __nr_to_section() returns NULL here, we should
just panic.  But a null-deref gives the same information, so why change
things?





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux