diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2015-08-05 18:11:59 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2015-08-05 18:11:59 +0200 |
commit | 7c5897933f4f64594602b2e38264af705c061754 (patch) | |
tree | b6051387f6e2ff6c995141ba9bcb6960ecdd0b6a /pcilib/kmem.c | |
parent | f2e47ba725cc7ba477d3a788addc974f2b18d36f (diff) | |
download | pcitool-7c5897933f4f64594602b2e38264af705c061754.tar.gz pcitool-7c5897933f4f64594602b2e38264af705c061754.tar.bz2 pcitool-7c5897933f4f64594602b2e38264af705c061754.tar.xz pcitool-7c5897933f4f64594602b2e38264af705c061754.zip |
Use global locks to protect kmem allocation to prevent race while allocating simmultaneously locking kmem pages and any other type of kmem
Diffstat (limited to 'pcilib/kmem.c')
-rw-r--r-- | pcilib/kmem.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/pcilib/kmem.c b/pcilib/kmem.c index 469c63a..b1d2c5c 100644 --- a/pcilib/kmem.c +++ b/pcilib/kmem.c @@ -80,7 +80,7 @@ pcilib_kmem_handle_t *pcilib_alloc_kernel_memory(pcilib_t *ctx, pcilib_kmem_type memset(kbuf, 0, sizeof(pcilib_kmem_list_t) + nmemb * sizeof(pcilib_kmem_addr_t)); - err = pcilib_lock(ctx->locks.mmap); + err = pcilib_lock_global(ctx); if (err) { pcilib_error("Error (%i) acquiring mmap lock", err); return NULL; @@ -88,7 +88,7 @@ pcilib_kmem_handle_t *pcilib_alloc_kernel_memory(pcilib_t *ctx, pcilib_kmem_type ret = ioctl( ctx->handle, PCIDRIVER_IOC_MMAP_MODE, PCIDRIVER_MMAP_KMEM ); if (ret) { - pcilib_unlock(ctx->locks.mmap); + pcilib_unlock_global(ctx); pcilib_error("PCIDRIVER_IOC_MMAP_MODE ioctl have failed"); return NULL; } @@ -176,7 +176,7 @@ pcilib_kmem_handle_t *pcilib_alloc_kernel_memory(pcilib_t *ctx, pcilib_kmem_type kbuf->buf.blocks[i].mmap_offset = kh.pa & ctx->page_mask; } - pcilib_unlock(ctx->locks.mmap); + pcilib_unlock_global(ctx); //This is possible in the case of error (nothing is allocated yet) or if buffers are not reused |