On Mon, May 03, 2010 at 05:50:44PM -0400, Bill Pemberton wrote:
> The return from k*alloc() should be checked and action taking for when
> the allocation fails.  In many places hv did this with an ASSERT()
> call or didn't check the value at all.
> 
> Signed-off-by: Bill Pemberton <[email protected]>
> ---
>  drivers/staging/hv/Channel.c     |   50 
> ++++++++++++++++++++++++++++----------
>  drivers/staging/hv/ChannelMgmt.c |    6 ++++-
>  drivers/staging/hv/Connection.c  |    4 +++
>  3 files changed, 46 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/staging/hv/Channel.c b/drivers/staging/hv/Channel.c
> index 328d3a0..94e5214 100644
> --- a/drivers/staging/hv/Channel.c
> +++ b/drivers/staging/hv/Channel.c
> @@ -181,6 +181,13 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, 
> u32 SendRingBufferSize,
>  
>       DPRINT_ENTER(VMBUS);
>  
> +     /* Create and init the channel open message */
> +     openInfo = kmalloc(sizeof(*openInfo) +
> +                        sizeof(struct vmbus_channel_open_channel),
> +                        GFP_KERNEL);
> +     if (!openInfo)
> +             return -ENOMEM;
> +
>       /* Aligned to page size */
>       ASSERT(!(SendRingBufferSize & (PAGE_SIZE - 1)));
>       ASSERT(!(RecvRingBufferSize & (PAGE_SIZE - 1)));
> @@ -226,12 +233,6 @@ int VmbusChannelOpen(struct vmbus_channel *NewChannel, 
> u32 SendRingBufferSize,
>                  NewChannel->Inbound.RingSize,
>                  SendRingBufferSize);
>  
> -     /* Create and init the channel open message */
> -     openInfo = kmalloc(sizeof(*openInfo) +
> -                        sizeof(struct vmbus_channel_open_channel),
> -                        GFP_KERNEL);
> -     ASSERT(openInfo != NULL);
> -

Why did you move this allocation up so high in the function?  You need
to then free it if the osd_PageAlloc() call fails, right?

Care to fix this up?

The other parts of the file look fine, but I would like to get Hank's
ack before applying it.  Care to respin it with this fix so he can test
it out?

thanks,

greg k-h
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

Reply via email to