Skip to contentSkip to conversation

f2fs-tools: fixed incorrect error handling

PATCH Superseded Maxim Korotkov 2 participants 3 messages Nov 20, 2023 – Nov 28, 2023 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs-tools: fixed incorrect error handling

lib/libf2fs_zoned.c +1 -0
index 56c97d1..81088af 100644
@@ -293,6 +293,7 @@ int f2fs_check_zones(int j)
 
 	dev->zone_cap_blocks = malloc(dev->nr_zones * sizeof(size_t));
 	if (!dev->zone_cap_blocks) {
+		free(rep);
 		ERR_MSG("No memory for zone capacity list.\n");
 		return -ENOMEM;
 	}
Signature · 8 lines
2.34.1



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
#1 lore raw

PATCH v2 1/1 f2fs-tools: fixed incorrect error handling

Case of failed memory allocation of dev->zone_cap_blocks doesn't release heap allocated rep
Found by RASU JSC

Fixes f8410857b7a8(f2fs-tools: zns zone-capacity support)

---
changeset:
- editted description

 lib/libf2fs_zoned.c | 1 +
 1 file changed, 1 insertion(+)
lib/libf2fs_zoned.c +1 -0
index 56c97d1..81088af 100644
@@ -293,6 +293,7 @@ int f2fs_check_zones(int j)
 
 	dev->zone_cap_blocks = malloc(dev->nr_zones * sizeof(size_t));
 	if (!dev->zone_cap_blocks) {
+		free(rep);
 		ERR_MSG("No memory for zone capacity list.\n");
 		return -ENOMEM;
 	}
Signature · 8 lines
2.34.1



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Reviewed-by on v2 1/1
#2 lore raw
Quoted 5 lines · Maxim Korotkov

Case of failed memory allocation of dev->zone_cap_blocks doesn't release heap allocated rep
Found by RASU JSC

Fixes f8410857b7a8(f2fs-tools: zns zone-capacity support)

Thanks,

_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel