Skip to content

Commit

Permalink
staging: hv: check return value of RingBufferInit()
Browse files Browse the repository at this point in the history
RingBufferInit() would always return sucess and instead relied on an
ASSERT() to test for an error condition.  Remove the ASSERT() and
return -EINVAL instead.  The return value of RingBufferInit() was also
never checked, so check it.

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 1bbdd7a commit 3324fb4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
13 changes: 11 additions & 2 deletions drivers/staging/hv/Channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,18 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, u32 SendRingBufferSize,
NewChannel->RingBufferPageCount = (SendRingBufferSize +
RecvRingBufferSize) >> PAGE_SHIFT;

RingBufferInit(&NewChannel->Outbound, out, SendRingBufferSize);
ret = RingBufferInit(&NewChannel->Outbound, out, SendRingBufferSize);
if (!ret) {
err = ret;
goto errorout;
}

ret = RingBufferInit(&NewChannel->Inbound, in, RecvRingBufferSize);
if (!ret) {
err = ret;
goto errorout;
}

RingBufferInit(&NewChannel->Inbound, in, RecvRingBufferSize);

/* Establish the gpadl for the ring buffer */
DPRINT_DBG(VMBUS, "Establishing ring buffer's gpadl for channel %p...",
Expand Down
3 changes: 2 additions & 1 deletion drivers/staging/hv/RingBuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,8 @@ u32 GetRingBufferInterruptMask(RING_BUFFER_INFO *rbi)
--*/
int RingBufferInit(RING_BUFFER_INFO *RingInfo, void *Buffer, u32 BufferLen)
{
ASSERT(sizeof(RING_BUFFER) == PAGE_SIZE);
if (sizeof(RING_BUFFER) != PAGE_SIZE)
return -EINVAL;

memset(RingInfo, 0, sizeof(RING_BUFFER_INFO));

Expand Down

0 comments on commit 3324fb4

Please sign in to comment.