tree data BUGFIX do not overwrite return value
diff --git a/src/tree_data.c b/src/tree_data.c
index 2d651b5..b2cf4d3 100644
--- a/src/tree_data.c
+++ b/src/tree_data.c
@@ -154,9 +154,9 @@
 
     if (!(parse_opts & LYD_PARSE_ONLY)) {
         /* validate data */
-        rc = lyd_validate(first_p, NULL, ctx, val_opts, 0, &lydctx->node_when, &lydctx->node_types, &lydctx->meta_types,
+        r = lyd_validate(first_p, NULL, ctx, val_opts, 0, &lydctx->node_when, &lydctx->node_types, &lydctx->meta_types,
                 &lydctx->ext_node, &lydctx->ext_val, NULL);
-        LY_CHECK_GOTO(rc, cleanup);
+        LY_CHECK_ERR_GOTO(r, rc = r, cleanup);
     }
 
     /* set the operation node */