Linux virtualization list
 help / color / mirror / Atom feed
From: Haiyang Zhang <haiyangz@microsoft.com>
To: haiyangz@microsoft.com, hjanssen@microsoft.com,
	kys@microsoft.com, gregkh@suse.de, linux-kernel@vger.kernel.org,
	devel@linuxdriverproject.org, virtualization@lists.osdl.org
Subject: [PATCH 09/10] staging: hv: fix the page buffer when rndis data go across page boundary
Date: Thu,  1 Sep 2011 12:19:47 -0700	[thread overview]
Message-ID: <1314904788-32746-10-git-send-email-haiyangz@microsoft.com> (raw)
In-Reply-To: <1314904788-32746-1-git-send-email-haiyangz@microsoft.com>

In rndis_filter_receive_data(), we need to drop the 0th page and move the
rest of pages forward if the rndis data go across page boundary, otherwise
the page offset will overflow.

Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
---
 drivers/staging/hv/rndis_filter.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/hv/rndis_filter.c b/drivers/staging/hv/rndis_filter.c
index 20e673d..b325345 100644
--- a/drivers/staging/hv/rndis_filter.c
+++ b/drivers/staging/hv/rndis_filter.c
@@ -323,6 +323,7 @@ static void rndis_filter_receive_data(struct rndis_device *dev,
 {
 	struct rndis_packet *rndis_pkt;
 	u32 data_offset;
+	int i;
 
 	rndis_pkt = &msg->msg.pkt;
 
@@ -338,6 +339,15 @@ static void rndis_filter_receive_data(struct rndis_device *dev,
 	pkt->page_buf[0].offset += data_offset;
 	pkt->page_buf[0].len -= data_offset;
 
+	/* Drop the 0th page, if rndis data go beyond page boundary */
+	if (pkt->page_buf[0].offset >= PAGE_SIZE) {
+		pkt->page_buf[1].offset = pkt->page_buf[0].offset - PAGE_SIZE;
+		pkt->page_buf[1].len -= pkt->page_buf[1].offset;
+		pkt->page_buf_cnt--;
+		for (i = 0; i < pkt->page_buf_cnt; i++)
+			pkt->page_buf[i] = pkt->page_buf[i+1];
+	}
+
 	pkt->is_data_pkt = true;
 
 	netvsc_recv_callback(dev->net_dev->dev, pkt);
-- 
1.6.3.2

  parent reply	other threads:[~2011-09-01 19:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-01 19:19 [PATCH 00/10] netvsc bug fixes and cleanups Haiyang Zhang
2011-09-01 19:19 ` [PATCH 01/10] staging: hv: remove unnecessary includes in netvsc Haiyang Zhang
2011-09-01 19:19 ` [PATCH 02/10] staging: hv: add newline to log messages " Haiyang Zhang
2011-09-01 19:19 ` [PATCH 03/10] staging: hv: convert dev_<loglevel> to netdev_<loglevel> " Haiyang Zhang
2011-09-01 19:19 ` [PATCH 04/10] staging: hv: fix a kernel warning in netvsc_linkstatus_callback() Haiyang Zhang
2011-09-01 19:19 ` [PATCH 05/10] staging: hv: re-order the code in netvsc_probe() Haiyang Zhang
2011-09-01 19:19 ` [PATCH 06/10] staging: hv: fix counting of #outstanding-sends in failed sends Haiyang Zhang
2011-09-01 19:19 ` [PATCH 07/10] staging: hv: fix counting of available buffer slots when send fails Haiyang Zhang
2011-09-01 19:19 ` [PATCH 08/10] staging: hv: fix the return status of netvsc_start_xmit() Haiyang Zhang
2011-09-01 19:19 ` Haiyang Zhang [this message]
2011-09-01 19:19 ` [PATCH 10/10] staging: hv: fix some typos in netvsc.c 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=1314904788-32746-10-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=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