In alloc_waiter func, if MALLOC fails, wp is equal to NULL.
If now we call memset(wp), segmentation fault will occur.

Signed-off-by: Zhiqiang Liu <liuzhiqian...@huawei.com>
Signed-off-by: lixiaokeng <lixiaok...@huawei.com>
---
 multipathd/waiter.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/multipathd/waiter.c b/multipathd/waiter.c
index e645766..80e6e6e 100644
--- a/multipathd/waiter.c
+++ b/multipathd/waiter.c
@@ -33,8 +33,10 @@ static struct event_thread *alloc_waiter (void)
        struct event_thread *wp;

        wp = (struct event_thread *)MALLOC(sizeof(struct event_thread));
-       memset(wp, 0, sizeof(struct event_thread));
+       if (!wp)
+               return NULL;

+       memset(wp, 0, sizeof(struct event_thread));
        return wp;
 }

-- 
1.8.3.1



--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

Reply via email to