msm:adsprpc: Prevent use after free in fastrpc_set_process_info

Serialize kzalloc in fastrpc_set_process_info and prevent use
after free.

Change-Id: I02d62182a234ef40ce33165247fc578f6727d27a
Signed-off-by: Anirudh Raghavendra <araghave@codeaurora.org>
This commit is contained in:
Anirudh Raghavendra 2020-07-29 16:01:39 -07:00
commit 54b949b8f9

View file

@ -5119,7 +5119,15 @@ static int fastrpc_set_process_info(struct fastrpc_file *fl)
if (debugfs_root) {
buf_size = strlen(current->comm) + strlen("_")
+ strlen(strpid) + 1;
spin_lock(&fl->hlock);
if (fl->debug_buf) {
spin_unlock(&fl->hlock);
return err;
}
fl->debug_buf = kzalloc(buf_size, GFP_KERNEL);
spin_unlock(&fl->hlock);
if (!fl->debug_buf) {
err = -ENOMEM;
return err;