summaryrefslogtreecommitdiffstats
path: root/protocols
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2015-08-06 01:12:55 +0200
committerSuren A. Chilingaryan <csa@suren.me>2015-08-06 01:12:55 +0200
commit56787b1553bd151eff62741e34fb3b4834073442 (patch)
tree61964f24d02ffdd57e5e65ed02007bda508a70aa /protocols
parent98fa817f608756b39223ed785b85dd5cace9b096 (diff)
downloadpcitool-56787b1553bd151eff62741e34fb3b4834073442.tar.gz
pcitool-56787b1553bd151eff62741e34fb3b4834073442.tar.bz2
pcitool-56787b1553bd151eff62741e34fb3b4834073442.tar.xz
pcitool-56787b1553bd151eff62741e34fb3b4834073442.zip
Minor fix for software registers
Diffstat (limited to 'protocols')
-rw-r--r--protocols/software.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/protocols/software.c b/protocols/software.c
index ed9d372..55f62e8 100644
--- a/protocols/software.c
+++ b/protocols/software.c
@@ -61,6 +61,7 @@ pcilib_register_bank_context_t* pcilib_software_registers_open(pcilib_t *ctx, pc
lock = pcilib_get_lock(ctx, PCILIB_LOCK_FLAGS_DEFAULT, "softreg/%s", bank_desc->name);
if (!lock) {
+ pcilib_software_registers_close(ctx, (pcilib_register_bank_context_t*)bank_ctx);
pcilib_error("Failed to initialize a lock to protect bank %s with software registers", bank_desc->name);
return NULL;
}
@@ -68,6 +69,7 @@ pcilib_register_bank_context_t* pcilib_software_registers_open(pcilib_t *ctx, pc
err = pcilib_lock(lock);
if (err) {
pcilib_return_lock(ctx, PCILIB_LOCK_FLAGS_DEFAULT, lock);
+ pcilib_software_registers_close(ctx, (pcilib_register_bank_context_t*)bank_ctx);
pcilib_error("Error (%i) obtaining lock on bank %s with software registers", err, bank_desc->name);
return NULL;
}
@@ -77,8 +79,8 @@ pcilib_register_bank_context_t* pcilib_software_registers_open(pcilib_t *ctx, pc
if (!handle) {
pcilib_unlock(lock);
pcilib_return_lock(ctx, PCILIB_LOCK_FLAGS_DEFAULT, lock);
- pcilib_error("Allocation of kernel memory for software registers has failed");
pcilib_software_registers_close(ctx, (pcilib_register_bank_context_t*)bank_ctx);
+ pcilib_error("Allocation of kernel memory for software registers has failed");
return NULL;
}
@@ -92,8 +94,8 @@ pcilib_register_bank_context_t* pcilib_software_registers_open(pcilib_t *ctx, pc
if (reused & PCILIB_KMEM_REUSE_PARTIAL) {
pcilib_unlock(lock);
pcilib_return_lock(ctx, PCILIB_LOCK_FLAGS_DEFAULT, lock);
- pcilib_error("Inconsistent software registers are found (only part of required buffers is available)");
pcilib_software_registers_close(ctx, (pcilib_register_bank_context_t*)bank_ctx);
+ pcilib_error("Inconsistent software registers are found (only part of required buffers is available)");
return NULL;
}