validation BUGFIX memory leak
diff --git a/src/validation.c b/src/validation.c
index 47b1afc..4ab3ffc 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -1372,7 +1372,8 @@
 lyd_validate_final_r(struct lyd_node *first, const struct lyd_node *parent, const struct lysc_node *sparent,
         const struct lys_module *mod, uint32_t val_opts, uint32_t int_opts)
 {
-    const char *innode = NULL;
+    LY_ERR r;
+    const char *innode;
     struct lyd_node *next = NULL, *node;
 
     /* validate all restrictions of nodes themselves */
@@ -1387,30 +1388,37 @@
         /* opaque data */
         if (!node->schema) {
             LOGVAL(LYD_CTX(node), LYVE_DATA, "Invalid opaque node \"%s\" found.", ((struct lyd_node_opaq *)node)->name.name);
-            LOG_LOCBACK(0, 1, 0, 0);
+            LOG_LOCBACK(1, 1, 0, 0);
             return LY_EVALID;
         }
 
         /* no state/input/output data */
+        innode = NULL;
         if ((val_opts & LYD_VALIDATE_NO_STATE) && (node->schema->flags & LYS_CONFIG_R)) {
             innode = "state";
-            goto unexpected_node;
         } else if ((int_opts & (LYD_INTOPT_RPC | LYD_INTOPT_ACTION)) && (node->schema->flags & LYS_IS_OUTPUT)) {
             innode = "output";
-            goto unexpected_node;
         } else if ((int_opts & LYD_INTOPT_REPLY) && (node->schema->flags & LYS_IS_INPUT)) {
             innode = "input";
-            goto unexpected_node;
+        }
+        if (innode) {
+            LOGVAL(LYD_CTX(node), LY_VCODE_UNEXPNODE, innode, node->schema->name);
+            LOG_LOCBACK(1, 1, 0, 0);
+            return LY_EVALID;
         }
 
         /* obsolete data */
         lyd_validate_obsolete(node);
 
         /* node's musts */
-        LY_CHECK_RET(lyd_validate_must(node, int_opts));
+        if ((r = lyd_validate_must(node, int_opts))) {
+            LOG_LOCBACK(1, 1, 0, 0);
+            return r;
+        }
 
         /* node value was checked by plugins */
 
+        /* next iter */
         LOG_LOCBACK(1, 1, 0, 0);
     }
 
@@ -1440,11 +1448,6 @@
     }
 
     return LY_SUCCESS;
-
-unexpected_node:
-    LOGVAL(LYD_CTX(node), LY_VCODE_UNEXPNODE, innode, node->schema->name);
-    LOG_LOCBACK(1, 1, 0, 0);
-    return LY_EVALID;
 }
 
 /**