Skip to content

Commit

Permalink
Staging: hv: remove ASSERT() in Channel.c
Browse files Browse the repository at this point in the history
check memory allocation in VmbusChannelCreateGpadlHeader() and
return -ENOMEM if it fails

Signed-off-by: Bill Pemberton <wfp5p@virginia.edu>
Cc: Hank Janssen <hjanssen@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Bill Pemberton authored and Greg Kroah-Hartman committed May 11, 2010
1 parent c3bf2e2 commit d1c250b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/staging/hv/Channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,8 @@ static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
sizeof(struct vmbus_channel_gpadl_header) +
sizeof(struct gpa_range) + pfnCount * sizeof(u64);
msgHeader = kzalloc(msgSize, GFP_KERNEL);
if (!msgHeader)
goto nomem;

INIT_LIST_HEAD(&msgHeader->SubMsgList);
msgHeader->MessageSize = msgSize;
Expand Down Expand Up @@ -416,7 +418,9 @@ static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
sizeof(struct vmbus_channel_gpadl_body) +
pfnCurr * sizeof(u64);
msgBody = kzalloc(msgSize, GFP_KERNEL);
ASSERT(msgBody);
/* FIXME: we probably need to more if this fails */
if (!msgBody)
goto nomem;
msgBody->MessageSize = msgSize;
(*MessageCount)++;
gpadlBody =
Expand Down Expand Up @@ -459,6 +463,10 @@ static int VmbusChannelCreateGpadlHeader(void *Kbuffer, u32 Size,
}

return 0;
nomem:
kfree(msgHeader);
kfree(msgBody);
return -ENOMEM;
}

/*
Expand Down

0 comments on commit d1c250b

Please sign in to comment.