diff --git a/common.c b/common.c
index 9a77177987203eada2edd608c8fcd2eb04c6c10d..d0dd10b02f799b257be12c1261771e9e72072031 100644
--- a/common.c
+++ b/common.c
@@ -102,10 +102,10 @@ leave:
 	return NULL;
 }
 
-void xml_to_json(xmlNode *anode, json_object *jobj)
+void xml_to_json(xmlNode *anode, struct json_object *jobj)
 {
 	xmlNodePtr cur_node = NULL;
-	json_object *cur_jstr = NULL;
+	struct json_object *cur_jstr = NULL;
 
 	for (cur_node = anode; cur_node; cur_node = cur_node->next) {
 		debug_print("child address: %p\n", cur_node);
@@ -127,21 +127,39 @@ void xml_to_json(xmlNode *anode, json_object *jobj)
 	}
 }
 
-void xml_to_json_converter(struct write_result *result)
+//free memory...
+struct json_object *xml_to_json_converter(struct write_result *result)
 {
-	json_object *jobj;
+	struct json_object *jobj;
 	xmlDocPtr doc_ptr = NULL;
 	xmlNode *origin_node = NULL;
 
-	jobj = json_object_new_object();
-
 	doc_ptr = xmlParseMemory(result->data, result->pos);
-	origin_node = doc_ptr ? xmlDocGetRootElement(doc_ptr) : NULL;
+	if (!doc_ptr)
+		goto fail_doc_ptr;
+
+	origin_node = xmlDocGetRootElement(doc_ptr);
+	if (!origin_node)
+		goto fail_origin_node;
 
 	jobj = json_object_new_object();
 	xml_to_json(origin_node, jobj);
 
 	debug_print("The json object created: %s\n", json_object_to_json_string(jobj));
+
+	if (doc_ptr)
+		xmlFreeDoc(doc_ptr);
+	if (origin_node)
+		free (origin_node);
+
+	return jobj;
+
+fail_origin_node:
+	if (doc_ptr)
+		xmlFreeDoc(doc_ptr);
+fail_doc_ptr:
+	return NULL;
+
 }
 
 int isdigits(const char *pin)
@@ -233,4 +251,4 @@ int check_response(struct json_object *response)
 	return 0;
 fail:
 	return -1;
-}
\ No newline at end of file
+}
diff --git a/common.h b/common.h
index 865417fa12fe5738b5c23d833c6445297697a0f1..94336510d72a0637af36bf282f620cfab2c17039 100644
--- a/common.h
+++ b/common.h
@@ -23,8 +23,8 @@
 #include <libxml/xpath.h>
 #include <libxml/xpathInternals.h>
 
-//#include "libmobile_hilink.h"
-#include "libmobile_zte.h"
+#include "libmobile_hilink.h"
+//#include "libmobile_zte.h"
 
 extern int debug;
 extern char *global_ip_addr;
@@ -35,7 +35,7 @@ extern struct ubus_context *global_ctx;
 		if (debug)                        \
 			fprintf(stderr, __VA_ARGS__); \
 	} while (0)
-
+/*
 #define TAG_CONTENT_SIZE 100
 
 struct write_result
@@ -43,6 +43,7 @@ struct write_result
 	char *data;
 	int pos;
 };
+*/
 
 char *get_ip(char *if_name);
 /**
@@ -76,7 +77,7 @@ int print_to_ubus(struct json_object *parsed_response, struct ubus_context *ctx,
 struct blob_buf json_to_blob(struct json_object *response, struct blob_buf bb);
 
 char *xml_parser(struct write_result *result, char *tag);
-void xml_to_json_converter(struct write_result *result);
+struct json_object *xml_to_json_converter(struct write_result *result);
 int isdigits(const char *pin);
 int validate_puk_format(char *puk);
 int validate_pin_format(char *pin);