ethdev: add a missing sanity check for Tx queue setup
[dpdk.git] / lib / librte_ivshmem / rte_ivshmem.c
index 7ca55ed..8fc4b57 100644 (file)
@@ -377,6 +377,8 @@ build_config(struct rte_ivshmem_metadata * metadata)
                        for (j = biggest_idx - 1; j >= i; j--) {
                                memcpy(&pages[j+1], &pages[j], sizeof(struct rte_memseg));
                                memset(&pages[j], 0, sizeof(struct rte_memseg));
+                               if (j == 0)
+                                       break;
                        }
 
                        /* put old biggest segment to its new place */
@@ -502,7 +504,22 @@ add_memzone_to_metadata(const struct rte_memzone * mz,
                                config->metadata->name);
                goto fail;
        }
+#ifdef RTE_LIBRTE_IVSHMEM
+       struct rte_mem_config *mcfg;
+       unsigned int idx;
+
+       mcfg = rte_eal_get_configuration()->mem_config;
+
+       rte_rwlock_write_lock(&mcfg->mlock);
 
+       idx = ((uintptr_t)mz - (uintptr_t)mcfg->memzone);
+       idx = idx / sizeof(struct rte_memzone);
+
+       /* mark the memzone not freeable */
+       mcfg->memzone[idx].ioremap_addr = mz->phys_addr;
+
+       rte_rwlock_write_unlock(&mcfg->mlock);
+#endif
        rte_spinlock_unlock(&config->sl);
        return 0;
 fail: