diff mbox series

fs/proc/task_mmu: fix uninitialized variable in pagemap_pmd_range()

Message ID 9d6eaba7-92f8-4a70-8765-38a519680a87@moroto.mountain (mailing list archive)
State New
Headers show
Series fs/proc/task_mmu: fix uninitialized variable in pagemap_pmd_range() | expand

Commit Message

Dan Carpenter June 13, 2024, 2:34 p.m. UTC
The "folio" pointer is tested for NULL, but it's either valid or
uninitialized.  Initialize it to NULL.

Fixes: 84f57f8b8914 ("fs/proc: move page_mapcount() to fs/proc/internal.h")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 fs/proc/task_mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Hildenbrand June 13, 2024, 2:47 p.m. UTC | #1
On 13.06.24 16:34, Dan Carpenter wrote:
> The "folio" pointer is tested for NULL, but it's either valid or
> uninitialized.  Initialize it to NULL.
> 
> Fixes: 84f57f8b8914 ("fs/proc: move page_mapcount() to fs/proc/internal.h")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>   fs/proc/task_mmu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index 631371cb80a0..6ed1f56b32b4 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -1492,7 +1492,7 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end,
>   		u64 flags = 0, frame = 0;
>   		pmd_t pmd = *pmdp;
>   		struct page *page = NULL;
> -		struct folio *folio;
> +		struct folio *folio = NULL;
>   
>   		if (vma->vm_flags & VM_SOFTDIRTY)
>   			flags |= PM_SOFT_DIRTY;

Acked-by: David Hildenbrand <david@redhat.com>

Thanks!
Muhammad Usama Anjum June 14, 2024, 7:09 a.m. UTC | #2
On 6/13/24 7:34 PM, Dan Carpenter wrote:
> The "folio" pointer is tested for NULL, but it's either valid or
> uninitialized.  Initialize it to NULL.
> 
> Fixes: 84f57f8b8914 ("fs/proc: move page_mapcount() to fs/proc/internal.h")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  fs/proc/task_mmu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> index 631371cb80a0..6ed1f56b32b4 100644
> --- a/fs/proc/task_mmu.c
> +++ b/fs/proc/task_mmu.c
> @@ -1492,7 +1492,7 @@ static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end,
>  		u64 flags = 0, frame = 0;
>  		pmd_t pmd = *pmdp;
>  		struct page *page = NULL;
> -		struct folio *folio;
> +		struct folio *folio = NULL;
>  
>  		if (vma->vm_flags & VM_SOFTDIRTY)
>  			flags |= PM_SOFT_DIRTY;
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
diff mbox series

Patch

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 631371cb80a0..6ed1f56b32b4 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -1492,7 +1492,7 @@  static int pagemap_pmd_range(pmd_t *pmdp, unsigned long addr, unsigned long end,
 		u64 flags = 0, frame = 0;
 		pmd_t pmd = *pmdp;
 		struct page *page = NULL;
-		struct folio *folio;
+		struct folio *folio = NULL;
 
 		if (vma->vm_flags & VM_SOFTDIRTY)
 			flags |= PM_SOFT_DIRTY;