Staging: hv: vmbus: Properly handle memory allocation failure in channel.c
authorK. Y. Srinivasan <kys@microsoft.com>
Mon, 6 Jun 2011 22:50:06 +0000 (15:50 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 7 Jun 2011 20:46:04 +0000 (13:46 -0700)
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>
drivers/staging/hv/channel.c

index 69b5641151e0b79eaf792949093ff74b5be2f826..1833f275d0f88c85777e660c6b9b85dc08789585 100644 (file)
@@ -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 =
This page took 0.025691 seconds and 5 git commands to generate.