kernel: optimize uid list reading
This commit is contained in:
@@ -56,7 +56,7 @@ static void do_update_uid(struct work_struct *work)
|
|||||||
char chr = 0;
|
char chr = 0;
|
||||||
loff_t pos = 0;
|
loff_t pos = 0;
|
||||||
loff_t line_start = 0;
|
loff_t line_start = 0;
|
||||||
char buf[128];
|
char buf[KSU_MAX_PACKAGE_NAME];
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ssize_t count =
|
ssize_t count =
|
||||||
ksu_kernel_read_compat(fp, &chr, sizeof(chr), &pos);
|
ksu_kernel_read_compat(fp, &chr, sizeof(chr), &pos);
|
||||||
@@ -69,7 +69,7 @@ static void do_update_uid(struct work_struct *work)
|
|||||||
&line_start);
|
&line_start);
|
||||||
|
|
||||||
struct uid_data *data =
|
struct uid_data *data =
|
||||||
kmalloc(sizeof(struct uid_data), GFP_ATOMIC);
|
kzalloc(sizeof(struct uid_data), GFP_ATOMIC);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -80,13 +80,13 @@ static void do_update_uid(struct work_struct *work)
|
|||||||
char *uid = strsep(&tmp, delim);
|
char *uid = strsep(&tmp, delim);
|
||||||
if (!uid || !package) {
|
if (!uid || !package) {
|
||||||
pr_err("update_uid: package or uid is NULL!\n");
|
pr_err("update_uid: package or uid is NULL!\n");
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 res;
|
u32 res;
|
||||||
if (kstrtou32(uid, 10, &res)) {
|
if (kstrtou32(uid, 10, &res)) {
|
||||||
pr_err("update_uid: uid parse err\n");
|
pr_err("update_uid: uid parse err\n");
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
data->uid = res;
|
data->uid = res;
|
||||||
strncpy(data->package, package, KSU_MAX_PACKAGE_NAME);
|
strncpy(data->package, package, KSU_MAX_PACKAGE_NAME);
|
||||||
|
|||||||
Reference in New Issue
Block a user