Commit d1c250bb authored by Bill Pemberton's avatar Bill Pemberton Committed by Greg Kroah-Hartman

Staging: hv: remove ASSERT() in Channel.c

check memory allocation in VmbusChannelCreateGpadlHeader() and
return -ENOMEM if it fails
Signed-off-by: default avatarBill Pemberton <wfp5p@virginia.edu>
Cc: Hank Janssen <hjanssen@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent c3bf2e26
...@@ -382,6 +382,8 @@ static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size, ...@@ -382,6 +382,8 @@ static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
sizeof(struct vmbus_channel_gpadl_header) + sizeof(struct vmbus_channel_gpadl_header) +
sizeof(struct gpa_range) + pfnCount * sizeof(u64); sizeof(struct gpa_range) + pfnCount * sizeof(u64);
msgHeader = kzalloc(msgSize, GFP_KERNEL); msgHeader = kzalloc(msgSize, GFP_KERNEL);
if (!msgHeader)
goto nomem;
INIT_LIST_HEAD(&msgHeader->SubMsgList); INIT_LIST_HEAD(&msgHeader->SubMsgList);
msgHeader->MessageSize = msgSize; msgHeader->MessageSize = msgSize;
...@@ -416,7 +418,9 @@ static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size, ...@@ -416,7 +418,9 @@ static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
sizeof(struct vmbus_channel_gpadl_body) + sizeof(struct vmbus_channel_gpadl_body) +
pfnCurr * sizeof(u64); pfnCurr * sizeof(u64);
msgBody = kzalloc(msgSize, GFP_KERNEL); msgBody = kzalloc(msgSize, GFP_KERNEL);
ASSERT(msgBody); /* FIXME: we probably need to more if this fails */
if (!msgBody)
goto nomem;
msgBody->MessageSize = msgSize; msgBody->MessageSize = msgSize;
(*MessageCount)++; (*MessageCount)++;
gpadlBody = gpadlBody =
...@@ -459,6 +463,10 @@ static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size, ...@@ -459,6 +463,10 @@ static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
} }
return 0; return 0;
nomem:
kfree(msgHeader);
kfree(msgBody);
return -ENOMEM;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment