schema_mount BUGFIX resource leak

Fix based on Synopsis Coverity.
diff --git a/src/plugins_exts/schema_mount.c b/src/plugins_exts/schema_mount.c
index 8661894..042bebb 100644
--- a/src/plugins_exts/schema_mount.c
+++ b/src/plugins_exts/schema_mount.c
@@ -690,24 +690,24 @@
 LY_ERR
 lyplg_ext_schema_mount_get_parent_ref(const struct lysc_ext_instance *ext, struct ly_set **refs)
 {
-    LY_ERR res;
+    LY_ERR rc;
     struct ly_set *pref_set = NULL;
-    struct ly_set *snode_set;
+    struct ly_set *snode_set = NULL;
     struct ly_set *results_set = NULL;
     struct lyd_node *ext_data;
     ly_bool ext_data_free;
 
     /* get operational data with ietf-yang-library and ietf-yang-schema-mount data */
-    if ((res = lyplg_ext_get_data(ext->module->ctx, ext, (void **)&ext_data, &ext_data_free))) {
-        return res;
+    if ((rc = lyplg_ext_get_data(ext->module->ctx, ext, (void **)&ext_data, &ext_data_free))) {
+        return rc;
     }
 
-    LY_CHECK_GOTO(res = schema_mount_get_parent_ref(ext, ext_data, &pref_set), out);
+    LY_CHECK_GOTO(rc = schema_mount_get_parent_ref(ext, ext_data, &pref_set), cleanup);
     if (pref_set->count == 0) {
-        goto out;
+        goto cleanup;
     }
 
-    LY_CHECK_GOTO(res = ly_set_new(&results_set), out);
+    LY_CHECK_GOTO(rc = ly_set_new(&results_set), cleanup);
 
     for (uint32_t i = 0; i < pref_set->count; ++i) {
         struct lyd_node_term *term;
@@ -717,29 +717,29 @@
 
         term = (struct lyd_node_term *)pref_set->dnodes[i];
         LYD_VALUE_GET(&term->value, xp_val);
-        LY_CHECK_GOTO(res = lyplg_type_print_xpath10_value(xp_val, LY_VALUE_JSON, NULL, &value, &err), out);
-        LY_CHECK_ERR_GOTO(res = lys_find_xpath(ext->module->ctx, NULL, value, 0, &snode_set), free(value), out);
+        LY_CHECK_GOTO(rc = lyplg_type_print_xpath10_value(xp_val, LY_VALUE_JSON, NULL, &value, &err), cleanup);
+        LY_CHECK_ERR_GOTO(rc = lys_find_xpath(ext->module->ctx, NULL, value, 0, &snode_set), free(value), cleanup);
         free(value);
         for (uint32_t sn = 0; sn < snode_set->count; sn++) {
-            struct lysc_node *snode = snode_set->snodes[sn];
-
-            if ((res = ly_set_add(results_set, snode, 0, NULL))) {
-                ly_set_free(snode_set, NULL);
-                ly_set_free(results_set, NULL);
-                goto out;
-            }
+            LY_CHECK_GOTO(rc = ly_set_add(results_set, snode_set->snodes[sn], 0, NULL), cleanup);
         }
         ly_set_free(snode_set, NULL);
+        snode_set = NULL;
     }
 
     *refs = results_set;
 
-out:
+cleanup:
+    if (rc) {
+        ly_set_free(results_set, NULL);
+    }
+    ly_set_free(snode_set, NULL);
     if (ext_data_free) {
         lyd_free_all(ext_data);
     }
     ly_set_free(pref_set, NULL);
-    return res;
+
+    return rc;
 }
 
 /**