From 7c5897933f4f64594602b2e38264af705c061754 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Wed, 5 Aug 2015 18:11:59 +0200 Subject: Use global locks to protect kmem allocation to prevent race while allocating simmultaneously locking kmem pages and any other type of kmem --- pcilib/kmem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pcilib/kmem.c') 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 -- cgit v1.2.3