aboutsummaryrefslogtreecommitdiff
path: root/misc-utils/ftl_check.c
diff options
context:
space:
mode:
authorAnton Moryakov <ant.v.moryakov@gmail.com>2024-12-19 16:51:03 +0300
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2024-12-20 18:35:13 +0100
commit117efd252bc485084a609c405c312f5a9229e25a (patch)
tree9f843d196bbf7fe45fa5269bf9038aae58e38b83 /misc-utils/ftl_check.c
parent78f4f38bd3de8b5c590cbc09ce43812306207d95 (diff)
misc-utils: add missing error handling for 'bam' allocation in ftl_check.cHEADmaster
Corrections explained: Added robust handling for malloc() failure by checking the returnvalueand providing a clear error message. Triggers found by static analyzer Svace. Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'misc-utils/ftl_check.c')
-rw-r--r--misc-utils/ftl_check.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/misc-utils/ftl_check.c b/misc-utils/ftl_check.c
index 5b2dae5..fe6a91a 100644
--- a/misc-utils/ftl_check.c
+++ b/misc-utils/ftl_check.c
@@ -121,6 +121,10 @@ static void check_partition(int fd)
/* Create basic block allocation table for control blocks */
nbam = (mtd.erasesize >> hdr.BlockSize);
bam = malloc(nbam * sizeof(u_int));
+ if (!bam) {
+ perror("malloc failed");
+ return;
+ }
for (i = 0; i < le16_to_cpu(hdr.NumEraseUnits); i++) {
if (lseek(fd, (i << hdr.EraseUnitSize), SEEK_SET) == -1) {