lmkd: Handle cases when proc_get_name() might return NULL am: 9f1be12b9a

Original change: https://android-review.googlesource.com/c/platform/system/memory/lmkd/+/1685347

Change-Id: I048051fbbcf880642206e0a219171e7474fc677d
This commit is contained in:
Suren Baghdasaryan 2021-04-23 23:04:06 +00:00 committed by Automerger Merge Worker
commit d7838b8e06
2 changed files with 5 additions and 3 deletions

View File

@ -1150,9 +1150,10 @@ static void cmd_procprio(LMKD_CTRL_PACKET packet, int field_count, struct ucred
} else { } else {
if (!claim_record(procp, cred->pid)) { if (!claim_record(procp, cred->pid)) {
char buf[LINE_MAX]; char buf[LINE_MAX];
char *taskname = proc_get_name(cred->pid, buf, sizeof(buf));
/* Only registrant of the record can remove it */ /* Only registrant of the record can remove it */
ALOGE("%s (%d, %d) attempts to modify a process registered by another client", ALOGE("%s (%d, %d) attempts to modify a process registered by another client",
proc_get_name(cred->pid, buf, sizeof(buf)), cred->uid, cred->pid); taskname ? taskname : "A process ", cred->uid, cred->pid);
return; return;
} }
proc_unslot(procp); proc_unslot(procp);
@ -1187,9 +1188,10 @@ static void cmd_procremove(LMKD_CTRL_PACKET packet, struct ucred *cred) {
if (!claim_record(procp, cred->pid)) { if (!claim_record(procp, cred->pid)) {
char buf[LINE_MAX]; char buf[LINE_MAX];
char *taskname = proc_get_name(cred->pid, buf, sizeof(buf));
/* Only registrant of the record can remove it */ /* Only registrant of the record can remove it */
ALOGE("%s (%d, %d) attempts to unregister a process registered by another client", ALOGE("%s (%d, %d) attempts to unregister a process registered by another client",
proc_get_name(cred->pid, buf, sizeof(buf)), cred->uid, cred->pid); taskname ? taskname : "A process ", cred->uid, cred->pid);
return; return;
} }

View File

@ -262,7 +262,7 @@ void stats_remove_taskname(int pid) {
} }
void stats_store_taskname(int pid, const char* taskname) { void stats_store_taskname(int pid, const char* taskname) {
if (!enable_stats_log) { if (!enable_stats_log || !taskname) {
return; return;
} }