[dm-devel] [PATCH 6/6] multipathd: return NULL if MALLOC fails in alloc_waiteri, func
Zhiqiang Liu
liuzhiqiang26 at huawei.com
Sun Aug 16 01:46:29 UTC 2020
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 <liuzhiqiang26 at huawei.com>
Signed-off-by: lixiaokeng <lixiaokeng at 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
More information about the dm-devel
mailing list