From: "K. Y. Srinivasan" <kys@microsoft.com>
To: gregkh@suse.de, linux-kernel@vger.kernel.org,
devel@linuxdriverproject.org, virtualization@lists.osdl.org
Cc: "K. Y. Srinivasan" <kys@microsoft.com>,
Haiyang Zhang <haiyangz@microsoft.com>
Subject: [PATCH 1/4] Staging: hv: util: Deal with driver register failures
Date: Wed, 31 Aug 2011 14:35:54 -0700 [thread overview]
Message-ID: <1314826557-28755-1-git-send-email-kys@microsoft.com> (raw)
In-Reply-To: <1314826529-28716-1-git-send-email-kys@microsoft.com>
Properly deal with vmbus_driver_register() failures.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
---
drivers/staging/hv/hv_util.c | 21 ++++++++++++++++-----
1 files changed, 16 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/hv/hv_util.c b/drivers/staging/hv/hv_util.c
index e29a2a2..6039217 100644
--- a/drivers/staging/hv/hv_util.c
+++ b/drivers/staging/hv/hv_util.c
@@ -277,6 +277,7 @@ static struct hv_driver util_drv = {
static int __init init_hyperv_utils(void)
{
+ int ret;
pr_info("Registering HyperV Utility Driver\n");
if (hv_kvp_init())
@@ -289,12 +290,15 @@ static int __init init_hyperv_utils(void)
if (!shut_txf_buf || !time_txf_buf || !hbeat_txf_buf) {
pr_info("Unable to allocate memory for receive buffer\n");
- kfree(shut_txf_buf);
- kfree(time_txf_buf);
- kfree(hbeat_txf_buf);
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto err;
}
+ ret = vmbus_driver_register(&util_drv);
+
+ if (ret != 0)
+ goto err;
+
hv_cb_utils[HV_SHUTDOWN_MSG].callback = &shutdown_onchannelcallback;
hv_cb_utils[HV_TIMESYNC_MSG].callback = ×ync_onchannelcallback;
@@ -303,7 +307,14 @@ static int __init init_hyperv_utils(void)
hv_cb_utils[HV_KVP_MSG].callback = &hv_kvp_onchannelcallback;
- return vmbus_driver_register(&util_drv);
+ return 0;
+
+err:
+ kfree(shut_txf_buf);
+ kfree(time_txf_buf);
+ kfree(hbeat_txf_buf);
+
+ return ret;
}
static void exit_hyperv_utils(void)
--
1.7.4.1
next prev parent reply other threads:[~2011-08-31 21:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-31 21:35 [PATCH 0000/0004] Staging: hv: Driver cleanup K. Y. Srinivasan
2011-08-31 21:35 ` K. Y. Srinivasan [this message]
2011-08-31 21:35 ` [PATCH 2/4] Staging: hv: vmbus: Fix a bug in error handling in vmbus_bus_init() K. Y. Srinivasan
2011-08-31 21:35 ` [PATCH 3/4] Staging: hv: vmbus: Check for events before messages K. Y. Srinivasan
2011-08-31 21:35 ` [PATCH 4/4] Staging: hv: vmbus: Cleanup the code in process_chn_event() K. Y. Srinivasan
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=1314826557-28755-1-git-send-email-kys@microsoft.com \
--to=kys@microsoft.com \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@suse.de \
--cc=haiyangz@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=virtualization@lists.osdl.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;
as well as URLs for NNTP newsgroup(s).