* [PATCH][next] mm/shmem: Fix check on uninitialized pointer 'folio'
@ 2022-05-04 13:21 Colin Ian King
0 siblings, 0 replies; only message in thread
From: Colin Ian King @ 2022-05-04 13:21 UTC (permalink / raw)
To: Hugh Dickins, Andrew Morton, Matthew Wilcox, linux-mm
Cc: kernel-janitors, linux-kernel, llvm
In the case where shmem_swapin returns null, the jump to the error return
path via label 'failed' will end up with the uninitialized pointer folio
being null checked a few statements later. Fix this by ensuring folio is
initialized to null.
Detected by clang scan:
mm/shmem.c:1704:7: warning: variable 'folio' is used uninitialized
whenever 'if' condition is true [-Wsometimes-uninitialized]
Fixes: 2b58b3f33ba2 ("mm/shmem: convert shmem_swapin_page() to shmem_swapin_folio()")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
mm/shmem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/shmem.c b/mm/shmem.c
index 107f1e4dd0aa..7faaa61ff7fa 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -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;
--
2.35.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-04 13:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-04 13:21 [PATCH][next] mm/shmem: Fix check on uninitialized pointer 'folio' Colin Ian King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).