Skip to contentSkip to conversation

mm/shmem: initialize folio to NULL

PATCH In review Tom Rix 2 participants 4 messages May 9, 2022

Subsystems (2)
lore
Share & tools
lore

Tom Rix

author
#0 lore raw

PATCH 1/1 mm/shmem: initialize folio to NULL

The clang build fails with
mm/shmem.c:1704:7: error: variable 'folio' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]

  if (!page) {
       ^~~~~

The error handler for !page jumps to an if-check for an unset folio. So initialize folio to NULL.

Fixes 2b58b3f33ba2 ("mm/shmem: convert shmem_swapin_page() to shmem_swapin_folio()")
---
 mm/shmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/shmem.c +1 -1
index 107f1e4dd0aa..7faaa61ff7fa 100644
@@ -1682,7 +1682,7 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index,
 	struct shmem_inode_info *info = SHMEM_I(inode);
 	struct mm_struct *charge_mm = vma ? vma->vm_mm : NULL;
 	struct page *page;
-	struct folio *folio;
+	struct folio *folio = NULL;
 	swp_entry_t swap;
 	int error;
 
Signature · 1 line
2.27.0
#1 lore raw
Quoted 6 lines · Tom Rix

The clang build fails with
mm/shmem.c:1704:7: error: variable 'folio' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]

  if (!page) {
       ^~~~~

The error handler for !page jumps to an if-check for an unset folio. So initialize folio to NULL.

I appreciate you're trying to help, but the fourth report of a problem adds more noise than utility.

https://lore.kernel.org/linux-mm/?q=shmem+folio

shows emails about this from the cgelbot, Dan Carpenter, SeongJae Park, Colin King, Nathan Chancellor and Sebastian Siewior. So actually you were seventh, not fourth.

author
#2 lore raw
Quoted 7 lines · Matthew Wilcox
Quoted 6 lines · Tom Rix

The clang build fails with
mm/shmem.c:1704:7: error: variable 'folio' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]

   if (!page) {
        ^~~~~

The error handler for !page jumps to an if-check for an unset folio. So initialize folio to NULL.

Quoted 8 lines

I appreciate you're trying to help, but the fourth report of a problem adds more noise than utility.

https://lore.kernel.org/linux-mm/?q=shmem+folio

shows emails about this from the cgelbot, Dan Carpenter, SeongJae Park, Colin King, Nathan Chancellor and Sebastian Siewior. So actually you were seventh, not fourth.

From my point of view, the build has been broken for a week.

It would be good if this and the other folio issue was fixed in linux-next soon.

Tom

Quoted 1 line
#3 lore raw
Quoted 12 lines · Tom Rix
Quoted 10 lines · Matthew Wilcox
Quoted 6 lines · Tom Rix

The clang build fails with
mm/shmem.c:1704:7: error: variable 'folio' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]

   if (!page) {
        ^~~~~

The error handler for !page jumps to an if-check for an unset folio. So initialize folio to NULL.

I appreciate you're trying to help, but the fourth report of a problem adds more noise than utility.

Quoted 7 lines
Quoted 5 lines

https://lore.kernel.org/linux-mm/?q=shmem+folio

shows emails about this from the cgelbot, Dan Carpenter, SeongJae Park, Colin King, Nathan Chancellor and Sebastian Siewior. So actually you were seventh, not fourth.

From my point of view, the build has been broken for a week.

Yeah, shit happens when you're trying to fix patches and attend a conference at the same time.

Quoted 2 lines

It would be good if this and the other folio issue was fixed in linux-next soon.

As you can see, I sent a replacement patch series on the 4th which fixes far more than the two problems you noticed.
https://lore.kernel.org/linux-mm/[email protected]/

I can do no more than this.