[dm-devel] [PATCH 06/14] kpartx: check return value of malloc in main func
lixiaokeng
lixiaokeng at huawei.com
Wed Sep 2 07:19:14 UTC 2020
In main func of kpartx.c, we should check return value of
malloc before using it.
Signed-off-by: Zhiqiang Liu <liuzhiqiang26 at huawei.com>
Signed-off-by: Lixiaokeng <lixiaokeng at huawei.com>
---
kpartx/kpartx.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c
index 98f6176e..2f6dea7c 100644
--- a/kpartx/kpartx.c
+++ b/kpartx/kpartx.c
@@ -384,6 +384,10 @@ main(int argc, char **argv){
if (delim == NULL) {
delim = malloc(DELIM_SIZE);
+ if (!delim) {
+ fprintf(stderr, "malloc delim failed.\n");
+ exit(1);
+ }
memset(delim, 0, DELIM_SIZE);
set_delimiter(mapname, delim);
}
--
More information about the dm-devel
mailing list