diff options
author | Anton Moryakov <ant.v.moryakov@gmail.com> | 2024-12-19 16:51:03 +0300 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2024-12-20 18:35:13 +0100 |
commit | 117efd252bc485084a609c405c312f5a9229e25a (patch) | |
tree | 9f843d196bbf7fe45fa5269bf9038aae58e38b83 | |
parent | 78f4f38bd3de8b5c590cbc09ce43812306207d95 (diff) |
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>
-rw-r--r-- | misc-utils/ftl_check.c | 4 |
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) { |