staging: hv: check return value of RingBufferInit()
authorBill Pemberton <wfp5p@virginia.edu>
Wed, 5 May 2010 19:27:49 +0000 (15:27 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 11 May 2010 18:36:14 +0000 (11:36 -0700)
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>
drivers/staging/hv/Channel.c
drivers/staging/hv/RingBuffer.c

index a1431e4ac8be0e1722ee4a7a2ffb0f24d9e31a9f..158f62d8553af66444a88cfb006b1da18103fa0d 100644 (file)
@@ -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...",
index ee481fd972b77f24753df054c8ddd0c39cc800c6..69f3ebae15a92686cb0e854bd924020b2438f02e 100644 (file)
@@ -301,7 +301,8 @@ Description:
 --*/
 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));