[Feature][ZXW-265]merge P56U03 version

Only Configure: No
Affected branch: master
Affected module: unknow
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No

Change-Id: I873f6df64e2605a77b8b8bfec35b21e7f33c5444
diff --git a/ap/os/linux/linux-3.4.x/lib/kobject.c b/ap/os/linux/linux-3.4.x/lib/kobject.c
old mode 100644
new mode 100755
index d90c692..d969d5b
--- a/ap/os/linux/linux-3.4.x/lib/kobject.c
+++ b/ap/os/linux/linux-3.4.x/lib/kobject.c
@@ -76,7 +76,7 @@
 	return length;
 }
 
-static void fill_kobj_path(struct kobject *kobj, char *path, int length)
+static int fill_kobj_path(struct kobject *kobj, char *path, int length)
 {
 	struct kobject *parent;
 
@@ -85,12 +85,15 @@
 		int cur = strlen(kobject_name(parent));
 		/* back up enough to print this name with '/' */
 		length -= cur;
+		if (length <= 0)
+			return -EINVAL;
 		strncpy(path + length, kobject_name(parent), cur);
 		*(path + --length) = '/';
 	}
 
 	pr_debug("kobject: '%s' (%p): %s: path = '%s'\n", kobject_name(kobj),
 		 kobj, __func__, path);
+	return 0;
 }
 
 /**
@@ -106,13 +109,17 @@
 	char *path;
 	int len;
 
+retry:
 	len = get_kobj_path_length(kobj);
 	if (len == 0)
 		return NULL;
 	path = kzalloc(len, gfp_mask);
 	if (!path)
 		return NULL;
-	fill_kobj_path(kobj, path, len);
+	if (fill_kobj_path(kobj, path, len)) {
+		kfree(path);
+		goto retry;
+	}
 
 	return path;
 }