summaryrefslogtreecommitdiffstats
path: root/drivers/hv/hv_utils_transport.c
diff options
context:
space:
mode:
authorOlaf Hering <olaf@aepfle.de>2015-12-15 01:01:36 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-12-15 04:12:21 +0100
commitcdc0c0c94e4e6dfa371d497a3130f83349b6ead6 (patch)
tree4fe6bd6427ac2cb354cc3655bc4e21ccf57965ed /drivers/hv/hv_utils_transport.c
parenttools: hv: remove repeated HV_FCOPY string (diff)
downloadlinux-cdc0c0c94e4e6dfa371d497a3130f83349b6ead6.tar.xz
linux-cdc0c0c94e4e6dfa371d497a3130f83349b6ead6.zip
Drivers: hv: util: catch allocation errors
Catch allocation errors in hvutil_transport_send. Fixes: 14b50f80c32d ('Drivers: hv: util: introduce hv_utils_transport abstraction') Signed-off-by: Olaf Hering <olaf@aepfle.de> Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hv/hv_utils_transport.c')
-rw-r--r--drivers/hv/hv_utils_transport.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/hv/hv_utils_transport.c b/drivers/hv/hv_utils_transport.c
index 6a9d80a5332d..1505ee6e6605 100644
--- a/drivers/hv/hv_utils_transport.c
+++ b/drivers/hv/hv_utils_transport.c
@@ -204,9 +204,12 @@ int hvutil_transport_send(struct hvutil_transport *hvt, void *msg, int len)
goto out_unlock;
}
hvt->outmsg = kzalloc(len, GFP_KERNEL);
- memcpy(hvt->outmsg, msg, len);
- hvt->outmsg_len = len;
- wake_up_interruptible(&hvt->outmsg_q);
+ if (hvt->outmsg) {
+ memcpy(hvt->outmsg, msg, len);
+ hvt->outmsg_len = len;
+ wake_up_interruptible(&hvt->outmsg_q);
+ } else
+ ret = -ENOMEM;
out_unlock:
mutex_unlock(&hvt->outmsg_lock);
return ret;