diff --git a/src/utils/keymgr/functions.c b/src/utils/keymgr/functions.c
index 52cafd751e2ee930abf39625ff7c42f3ad10c1b6..924aca8aa4562cb5a3e996a4841104f5d97a9514 100644
--- a/src/utils/keymgr/functions.c
+++ b/src/utils/keymgr/functions.c
@@ -260,7 +260,7 @@ int keymgr_import_bind(kdnssec_ctx_t *ctx, const char *import_file, bool pub_onl
 		bind_privkey_t bpriv = { 0 };
 
 		char *privname = genname(import_file, ".private", ".key");
-		if (ret != KNOT_EOK) {
+		if (privname == NULL) {
 			goto fail;
 		}