Skip to contentSkip to conversation

dm-pcache: fix uninitialized variable issue

PATCH In review Dongsheng Yang 2 participants 3 messages Aug 15, 2025

Subsystems (2)
lore
Share & tools
lore

Dongsheng Yang

author maintainer
#0 lore raw

PATCH 1/1 dm-pcache: fix uninitialized variable issue

The 'ret' varialbe may be returned without initialized in some branch, this patch make sure it is initialized correctly with 0.

Fixes 6fb8fbbaf147 ("dm-pcache: add persistent cache target in device-mapper")
---
 drivers/md/dm-pcache/cache_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-pcache/cache_dev.c +1 -1
index 722d7e952262..a7dafe8d35f7 100644
@@ -21,7 +21,7 @@ static int build_vmap(struct dax_device *dax_dev, long total_pages, void **vaddr
 	struct page **pages;
 	long i = 0, chunk;
 	unsigned long pfn;
-	int ret;
+	int ret = 0;
 
 	pages = vmalloc_array(total_pages, sizeof(struct page *));
 	if (!pages)
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 2 lines · Dongsheng Yang

The 'ret' varialbe may be returned without initialized in some branch, this patch make sure it is initialized correctly with 0.

Hi

I've already fixed it (and I folded the fix into the existing commit).

Mikulas

Quoted 24 lines
Fixes 6fb8fbbaf147 ("dm-pcache: add persistent cache target in device-mapper")
---
 drivers/md/dm-pcache/cache_dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-pcache/cache_dev.c +1 -1
index 722d7e952262..a7dafe8d35f7 100644
@@ -21,7 +21,7 @@ static int build_vmap(struct dax_device *dax_dev, long total_pages, void **vaddr
 	struct page **pages;
 	long i = 0, chunk;
 	unsigned long pfn;
-	int ret;
+	int ret = 0;
 
 	pages = vmalloc_array(total_pages, sizeof(struct page *));
 	if (!pages)
Signature · 1 line
2.43.0
author maintainer
#2 lore raw
Quoted 8 lines · Mikulas Patocka
Quoted 2 lines · Dongsheng Yang

The 'ret' varialbe may be returned without initialized in some branch, this patch make sure it is initialized correctly with 0.

Hi

I've already fixed it (and I folded the fix into the existing commit).

Okey, thanx

Dongsheng

Quoted 27 lines

Mikulas

Quoted 24 lines
Fixes 6fb8fbbaf147 ("dm-pcache: add persistent cache target in device-mapper")
---
  drivers/md/dm-pcache/cache_dev.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-pcache/cache_dev.c +1 -1
index 722d7e952262..a7dafe8d35f7 100644
@@ -21,7 +21,7 @@ static int build_vmap(struct dax_device *dax_dev, long total_pages, void **vaddr
  	struct page **pages;
  	long i = 0, chunk;
  	unsigned long pfn;
-	int ret;
+	int ret = 0;
 
  	pages = vmalloc_array(total_pages, sizeof(struct page *));
  	if (!pages)
Signature · 1 line
2.43.0