staging: hv: fix the page buffer when rndis data go across page boundary
authorHaiyang Zhang <haiyangz@microsoft.com>
Thu, 1 Sep 2011 19:19:47 +0000 (12:19 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 6 Sep 2011 18:56:19 +0000 (11:56 -0700)
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/hv/rndis_filter.c

index 20e673d9e4b85c6295d69433c70767d369bb2cc5..b32534507d4e60c40749bf7e0a735d50db667fb1 100644 (file)
@@ -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);