mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>,
	devel@linuxdriverproject.org, linux-kernel@vger.kernel.org,
	Dexuan Cui <decui@microsoft.com>,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: [PATCH v2 1/3] Drivers: hv: vmbus: do cleanup on all vmbus_open() failure paths
Date: Tue, 21 Apr 2015 18:21:36 +0200	[thread overview]
Message-ID: <1429633298-31142-2-git-send-email-vkuznets@redhat.com> (raw)
In-Reply-To: <1429633298-31142-1-git-send-email-vkuznets@redhat.com>

In case there was an error reported in the response to the CHANNELMSG_OPENCHANNEL
call we need to do the cleanup as a vmbus_open() user won't be doing it after
receiving an error. The cleanup should be done on all failure paths. We also need
to avoid returning open_info->response.open_result.status as the return value as
all other errors we return from vmbus_open() are -EXXX and vmbus_open() callers
are not supposed to analyze host error codes.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 drivers/hv/channel.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
index 54da66d..7a1c2db 100644
--- a/drivers/hv/channel.c
+++ b/drivers/hv/channel.c
@@ -178,19 +178,18 @@ int vmbus_open(struct vmbus_channel *newchannel, u32 send_ringbuffer_size,
 		goto error1;
 	}
 
-
-	if (open_info->response.open_result.status)
-		err = open_info->response.open_result.status;
-
 	spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
 	list_del(&open_info->msglistentry);
 	spin_unlock_irqrestore(&vmbus_connection.channelmsg_lock, flags);
 
-	if (err == 0)
-		newchannel->state = CHANNEL_OPENED_STATE;
+	if (open_info->response.open_result.status) {
+		err = -EAGAIN;
+		goto error_gpadl;
+	}
 
+	newchannel->state = CHANNEL_OPENED_STATE;
 	kfree(open_info);
-	return err;
+	return 0;
 
 error1:
 	spin_lock_irqsave(&vmbus_connection.channelmsg_lock, flags);
-- 
1.9.3


  reply	other threads:[~2015-04-21 16:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-21 16:21 [PATCH v2 0/3] Drivers: hv: vmbus: additional fixes for the setup/teardown path Vitaly Kuznetsov
2015-04-21 16:21 ` Vitaly Kuznetsov [this message]
2015-04-21 16:21 ` [PATCH v2 2/3] Drivers: hv: vmbus: kill tasklets on module unload Vitaly Kuznetsov
2015-04-21 16:21 ` [PATCH v2 3/3] Drivers: hv: vmbus: setup irq after synic is initialized Vitaly Kuznetsov
2015-05-03  1:58   ` KY Srinivasan
2015-05-12 16:34     ` Vitaly Kuznetsov
2015-04-24  9:14 ` [PATCH v2 0/3] Drivers: hv: vmbus: additional fixes for the setup/teardown path Dexuan Cui
2015-04-24  9:24   ` Vitaly Kuznetsov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1429633298-31142-2-git-send-email-vkuznets@redhat.com \
    --to=vkuznets@redhat.com \
    --cc=dan.carpenter@oracle.com \
    --cc=decui@microsoft.com \
    --cc=devel@linuxdriverproject.org \
    --cc=haiyangz@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®