From mboxrd@z Thu Jan 1 00:00:00 1970 From: lixiaokeng Subject: [PATCH 02/14] libmultipath: check malloc return value in, print_foreign_topology Date: Wed, 2 Sep 2020 15:16:43 +0800 Message-ID: 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 We check the return value of malloc in print_foreign_topology. Signed-off-by: Lixiaokeng Signed-off-by: Zhiqiang Liu Signed-off-by: Linfeilong --- libmultipath/foreign.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libmultipath/foreign.c b/libmultipath/foreign.c index e8f61351..44f32d03 100644 --- a/libmultipath/foreign.c +++ b/libmultipath/foreign.c @@ -545,6 +545,10 @@ void print_foreign_topology(int verbosity) char *buf = NULL, *tmp = NULL; buf = malloc(buflen); + if (!buf) { + condlog (0, "malloc buf failed."); + return; + } buf[0] = '\0'; while (buf != NULL) { char *c = buf; --