summaryrefslogtreecommitdiff
path: root/drivers/staging/hv
diff options
context:
space:
mode:
authorK. Y. Srinivasan <kys@microsoft.com>2011-06-06 15:50:06 -0700
committerGreg Kroah-Hartman <gregkh@suse.de>2011-06-07 13:46:04 -0700
commitf38cf9ccd61d2acd5bc9121fabf2f6e77d74b885 (patch)
treee0d27b00eadaf33bdcaa225121b2a6863c6a0810 /drivers/staging/hv
parent40961de3350b99cfa93cd80437cb39ec287f839a (diff)
Staging: hv: vmbus: Properly handle memory allocation failure in channel.c
Properly handle memory allocation failure in channel.c. Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com> Signed-off-by: Abhishek Kane <v-abkane@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/hv')
-rw-r--r--drivers/staging/hv/channel.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/drivers/staging/hv/channel.c b/drivers/staging/hv/channel.c
index 69b5641151e0..1833f275d0f8 100644
--- a/drivers/staging/hv/channel.c
+++ b/drivers/staging/hv/channel.c
@@ -355,9 +355,24 @@ static int create_gpadl_header(void *kbuffer, u32 size,
sizeof(struct vmbus_channel_gpadl_body) +
pfncurr * sizeof(u64);
msgbody = kzalloc(msgsize, GFP_KERNEL);
- /* FIXME: we probably need to more if this fails */
- if (!msgbody)
+
+ if (!msgbody) {
+ struct vmbus_channel_msginfo *pos = NULL;
+ struct vmbus_channel_msginfo *tmp = NULL;
+ /*
+ * Free up all the allocated messages.
+ */
+ list_for_each_entry_safe(pos, tmp,
+ &msgheader->submsglist,
+ msglistentry) {
+
+ list_del(&pos->msglistentry);
+ kfree(pos);
+ }
+
goto nomem;
+ }
+
msgbody->msgsize = msgsize;
(*messagecount)++;
gpadl_body =