[dm-devel] [PATCH V4 05/14] multipathd: check return value of malloc in cli_getprkey func

lixiaokeng lixiaokeng at huawei.com
Thu Sep 10 10:49:27 UTC 2020


In cli_getprkey func, we check the return value of malloc.

Signed-off-by: Zhiqiang Liu <liuzhiqiang26 at huawei.com>
Signed-off-by: Lixiaokeng <lixiaokeng at huawei.com>
Signed-off-by: Linfeilong <linfeilong at huawei.com>
---
 multipathd/cli_handlers.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c
index e9698704..235e2a2e 100644
--- a/multipathd/cli_handlers.c
+++ b/multipathd/cli_handlers.c
@@ -1531,6 +1531,8 @@ cli_getprkey(void * v, char ** reply, int * len, void * data)
 		return 1;

 	*reply = malloc(26);
+	if (!*reply)
+		return 1;

 	if (!get_be64(mpp->reservation_key)) {
 		sprintf(*reply, "none\n");
-- 




More information about the dm-devel mailing list