From mboxrd@z Thu Jan 1 00:00:00 1970 From: lixiaokeng Subject: [PATCH 05/14] multipathd: use MALLOC and check return value in, cli_getprkey func Date: Wed, 2 Sep 2020 15:18:37 +0800 Message-ID: <5edc1c2b-eb21-198b-9880-3be6621496f9@huawei.com> References: <37544d4c-950f-4281-3b66-e4d1884c5167@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <37544d4c-950f-4281-3b66-e4d1884c5167@huawei.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com Content-Language: en-GB To: Martin Wilck , Benjamin Marzinski , Christophe Varoqui , dm-devel mailing list Cc: linfeilong , "liuzhiqiang (I)" List-Id: dm-devel.ids In cli_getprkey func, we use MALLOC instead of malloc, and check the return value of MALLOC. Signed-off-by: Zhiqiang Liu Signed-off-by: Lixiaokeng Signed-off-by: Linfeilong --- multipathd/cli_handlers.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/multipathd/cli_handlers.c b/multipathd/cli_handlers.c index 27e4574f..d345afd3 100644 --- a/multipathd/cli_handlers.c +++ b/multipathd/cli_handlers.c @@ -1535,7 +1535,11 @@ cli_getprkey(void * v, char ** reply, int * len, void * data) if (!mpp) return 1; - *reply = malloc(26); + *reply = MALLOC(26); + if (!*reply) { + condlog(0, "malloc *reply failed."); + return 1; + } if (!get_be64(mpp->reservation_key)) { sprintf(*reply, "none\n"); --