From c377327fd756a2a7f0afad90dccbe97fe118206c Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Tue, 5 May 2015 16:23:18 +0200 Subject: Fix segmentation fault if requested register is not found --- pcilib/register.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pcilib') diff --git a/pcilib/register.c b/pcilib/register.c index f10e29b..347bf7c 100644 --- a/pcilib/register.c +++ b/pcilib/register.c @@ -160,7 +160,7 @@ int pcilib_read_register(pcilib_t *ctx, const char *bank, const char *regname, p int reg; reg = pcilib_find_register(ctx, bank, regname); - if (reg < 0) { + if (reg == PCILIB_REGISTER_INVALID) { pcilib_error("Register (%s) is not found", regname); return PCILIB_ERROR_NOTFOUND; } @@ -291,7 +291,7 @@ int pcilib_write_register(pcilib_t *ctx, const char *bank, const char *regname, int reg; reg = pcilib_find_register(ctx, bank, regname); - if (reg < 0) { + if (reg == PCILIB_REGISTER_INVALID) { pcilib_error("Register (%s) is not found", regname); return PCILIB_ERROR_NOTFOUND; } -- cgit v1.2.3