From: Haiyang Zhang <haiyangz@microsoft.com>
To: haiyangz@microsoft.com, hjanssen@microsoft.com,
kys@microsoft.com, v-abkane@microsoft.com, gregkh@suse.de,
linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
virtualization@lists.osdl.org
Subject: [PATCH 5/9] staging: hv: re-order the code in netvsc_probe()
Date: Thu, 21 Jul 2011 10:14:53 -0700 [thread overview]
Message-ID: <1311268497-8671-6-git-send-email-haiyangz@microsoft.com> (raw)
In-Reply-To: <1311268497-8671-1-git-send-email-haiyangz@microsoft.com>
Re-order the code in netvsc_probe() to prevent a guest crash caused by
packets possibly received from NetVSP before call to register_netdev().
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
drivers/staging/hv/netvsc_drv.c | 32 +++++++++++++++++---------------
1 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/drivers/staging/hv/netvsc_drv.c b/drivers/staging/hv/netvsc_drv.c
index c8e2f24..816e382 100644
--- a/drivers/staging/hv/netvsc_drv.c
+++ b/drivers/staging/hv/netvsc_drv.c
@@ -350,19 +350,6 @@ static int netvsc_probe(struct hv_device *dev)
dev_set_drvdata(&dev->device, net);
INIT_DELAYED_WORK(&net_device_ctx->dwork, netvsc_send_garp);
- /* Notify the netvsc driver of the new device */
- device_info.ring_size = ring_size;
- ret = rndis_filter_device_add(dev, &device_info);
- if (ret != 0) {
- free_netdev(net);
- dev_set_drvdata(&dev->device, NULL);
- return ret;
- }
-
- netif_carrier_on(net);
-
- memcpy(net->dev_addr, device_info.mac_adr, ETH_ALEN);
-
net->netdev_ops = &device_ops;
/* TODO: Add GSO and Checksum offload */
@@ -374,11 +361,26 @@ static int netvsc_probe(struct hv_device *dev)
ret = register_netdev(net);
if (ret != 0) {
- /* Remove the device and release the resource */
- rndis_filter_device_remove(dev);
+ pr_err("Unable to register netdev.\n");
free_netdev(net);
+ goto out;
}
+ /* Notify the netvsc driver of the new device */
+ device_info.ring_size = ring_size;
+ ret = rndis_filter_device_add(dev, &device_info);
+ if (ret != 0) {
+ netdev_err(net, "unable to add netvsc device (ret %d)\n", ret);
+ unregister_netdev(net);
+ free_netdev(net);
+ dev_set_drvdata(&dev->device, NULL);
+ return ret;
+ }
+ memcpy(net->dev_addr, device_info.mac_adr, ETH_ALEN);
+
+ netif_carrier_on(net);
+
+out:
return ret;
}
--
1.6.3.2
next prev parent reply other threads:[~2011-07-21 17:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-21 17:14 [PATCH 0/9] netvsc bug fixes and cleanups Haiyang Zhang
2011-07-21 17:14 ` [PATCH 1/9] staging: hv: remove unnecessary includes in netvsc Haiyang Zhang
2011-07-21 17:14 ` [PATCH 2/9] staging: hv: add newline to log messages " Haiyang Zhang
2011-07-22 1:35 ` Joe Perches
2011-07-22 14:22 ` Haiyang Zhang
2011-07-21 17:14 ` [PATCH 3/9] staging: hv: convert dev_<loglevel> to netdev_<loglevel> " Haiyang Zhang
2011-07-21 17:14 ` [PATCH 4/9] staging: hv: fix a kernel warning in netvsc_linkstatus_callback() Haiyang Zhang
2011-07-21 17:14 ` Haiyang Zhang [this message]
2011-07-21 17:14 ` [PATCH 6/9] staging: hv: fix counting of #outstanding-sends in failed sends Haiyang Zhang
2011-07-21 17:14 ` [PATCH 7/9] staging: hv: fix counting of available buffer slots when send fails Haiyang Zhang
2011-07-21 17:14 ` [PATCH 8/9] staging: hv: fix the return status of netvsc_start_xmit() Haiyang Zhang
2011-07-21 17:14 ` [PATCH 9/9] staging: hv: fix the page buffer when rndis data go across page boundary Haiyang Zhang
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=1311268497-8671-6-git-send-email-haiyangz@microsoft.com \
--to=haiyangz@microsoft.com \
--cc=devel@linuxdriverproject.org \
--cc=gregkh@suse.de \
--cc=hjanssen@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-kernel@vger.kernel.org \
--cc=v-abkane@microsoft.com \
--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
all inboxes | Powered by JetHome®