linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 3/3] hv: vmbus_open(): reset the channel state on ENOMEM
@ 2015-02-02  4:37 Dexuan Cui
  2015-02-02  9:44 ` Jason Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Dexuan Cui @ 2015-02-02  4:37 UTC (permalink / raw)
  To: gregkh, linux-kernel, driverdev-devel, olaf, apw, jasowang, kys,
	vkuznets
  Cc: haiyangz

Without this patch, the state is put to CHANNEL_OPENING_STATE, and when
the driver is loaded next time, vmbus_open() will fail immediately due to
newchannel->state != CHANNEL_OPEN_STATE.

CC: "K. Y. Srinivasan" <kys@microsoft.com>
Signed-off-by: Dexuan Cui <decui@microsoft.com>
---

v2: this is a RESEND.

 drivers/hv/channel.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 2978f5e..26dcf26 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -89,9 +89,10 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 	out = (void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,
 		get_order(send_ringbuffer_size + recv_ringbuffer_size));
 
-	if (!out)
-		return -ENOMEM;
-
+	if (!out) {
+		err = -ENOMEM;
+		goto error0;
+	}
 
 	in = (void *)((unsigned long)out + send_ringbuffer_size);
 
@@ -199,6 +200,7 @@ error0:
 	free_pages((unsigned long)out,
 		get_order(send_ringbuffer_size + recv_ringbuffer_size));
 	kfree(open_info);
+	newchannel->state = CHANNEL_OPEN_STATE;
 	return err;
 }
 EXPORT_SYMBOL_GPL(vmbus_open);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 3/3] hv: vmbus_open(): reset the channel state on ENOMEM
  2015-02-02  4:37 [PATCH v2 3/3] hv: vmbus_open(): reset the channel state on ENOMEM Dexuan Cui
@ 2015-02-02  9:44 ` Jason Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Wang @ 2015-02-02  9:44 UTC (permalink / raw)
  To: Dexuan Cui
  Cc: gregkh, linux-kernel, driverdev-devel, olaf, apw, kys, vkuznets,
	haiyangz



On Mon, Feb 2, 2015 at 12:37 PM, Dexuan Cui <decui@microsoft.com> wrote:
> Without this patch, the state is put to CHANNEL_OPENING_STATE, and 
> when
> the driver is loaded next time, vmbus_open() will fail immediately 
> due to
> newchannel->state != CHANNEL_OPEN_STATE.
> 
> CC: "K. Y. Srinivasan" <kys@microsoft.com>
> Signed-off-by: Dexuan Cui <decui@microsoft.com>
> ---
> 
> v2: this is a RESEND.
> 
>  drivers/hv/channel.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
> index 2978f5e..26dcf26 100644
> --- a/drivers/hv/channel.c
> +++ b/drivers/hv/channel.c
> @@ -89,9 +89,10 @@ int vmbus_open(struct vmbus_channel *newchannel, 
> u32 send_ringbuffer_size,
>  	out = (void *)__get_free_pages(GFP_KERNEL|__GFP_ZERO,
>  		get_order(send_ringbuffer_size + recv_ringbuffer_size));
>  
> -	if (!out)
> -		return -ENOMEM;
> -
> +	if (!out) {
> +		err = -ENOMEM;
> +		goto error0;
> +	}
>  
>  	in = (void *)((unsigned long)out + send_ringbuffer_size);
>  
> @@ -199,6 +200,7 @@ error0:
>  	free_pages((unsigned long)out,
>  		get_order(send_ringbuffer_size + recv_ringbuffer_size));
>  	kfree(open_info);
> +	newchannel->state = CHANNEL_OPEN_STATE;
>  	return err;
>  }
>  EXPORT_SYMBOL_GPL(vmbus_open);
> -- 
> 1.9.1

Reviewed-by: Jason Wang <jasowang@redhat.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-02-02  9:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-02  4:37 [PATCH v2 3/3] hv: vmbus_open(): reset the channel state on ENOMEM Dexuan Cui
2015-02-02  9:44 ` Jason Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).