diff options
author | Wenchao Hao <haowenchao@huawei.com> | 2020-11-24 17:05:19 +0800 |
---|---|---|
committer | Wenchao Hao <haowenchao@huawei.com> | 2020-12-12 11:44:13 +0800 |
commit | 86d3dae4d3e6030dfc5dee9712ae8fccd5262f5f (patch) | |
tree | 81cf1fee41a7e1adf1a711500add2268ca112650 | |
parent | 67c757749b91efa26352316a6077eab9ceb9a0bd (diff) | |
download | open-iscsi-86d3dae4d3e6030dfc5dee9712ae8fccd5262f5f.tar.gz |
open-iscsi: Fix NULL pointer dereference in mgmt_ipc_read_req()
If malloc() returns NULL on fail, we should return -ENOMEM to
avoid NULL pointer dereference.
Signed-off-by: Wenchao Hao <haowenchao@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: Wu Bo <wubo40@huawei.com>
-rw-r--r-- | usr/mgmt_ipc.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/usr/mgmt_ipc.c b/usr/mgmt_ipc.c index c292161..054378e 100644 --- a/usr/mgmt_ipc.c +++ b/usr/mgmt_ipc.c @@ -453,8 +453,11 @@ mgmt_ipc_read_req(queue_task_t *qtask) /* Remember the allocated pointer in the * qtask - it will be freed by write_rsp. * Note: we allocate one byte in excess - * so we can append a NUL byte. */ + * so we can append a NULL byte. */ qtask->payload = malloc(req->payload_len + 1); + if (!qtask->payload) + return -ENOMEM; + rc = mgmt_ipc_read_data(qtask->mgmt_ipc_fd, qtask->payload, req->payload_len); |