Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Cleanup and sanity-checking of unintentional integer overflow, unsigned/zero comparis...
[palacios.git] / palacios / src / devices / lnx_virtio_nic.c
index 7ead43d..b22a5be 100644 (file)
@@ -198,6 +198,11 @@ static int virtio_deinit_state(struct guest_info *core, struct virtio_net_state
     if (ns->timer) { 
        v3_remove_timer(core,ns->timer);
     }
+
+    v3_lock_deinit(&(ns->rx_lock));
+    v3_lock_deinit(&(ns->tx_lock));
+
+
     return 0;
 }
 
@@ -569,7 +574,7 @@ static int virtio_io_read(struct guest_info *core,
                             virtio->pci_dev, 0);
            break;
 
-       case VIRTIO_NET_CONFIG ... VIRTIO_NET_CONFIG + ETH_ALEN:
+       case VIRTIO_NET_CONFIG ... VIRTIO_NET_CONFIG + ETH_ALEN - 1:
            *(uint8_t *)dst = virtio->net_cfg.mac[port_idx-VIRTIO_NET_CONFIG];
            break;
 
@@ -607,7 +612,8 @@ static int virtio_rx(uint8_t * buf, uint32_t size, void * private_data) {
     if (q->cur_avail_idx != q->avail->index){
        uint16_t buf_idx;
        struct vring_desc * buf_desc;
-       uint32_t hdr_len, len;
+       uint32_t hdr_len;
+       int len;
        uint32_t offset = 0;
 
        hdr_len = (virtio->mergeable_rx_bufs)?
@@ -753,9 +759,6 @@ static int virtio_free(struct virtio_dev_state * virtio) {
        V3_Free(backend);
     }
 
-    v3_lock_deinit(&(virtio->rx_lock));
-    v3_lock_deinit(&(virtio->tx_lock));
-
     V3_Free(virtio);
 
     return 0;