From 3cb776ebaa71d6ab9a8a3ec95dcefa62d222bb79 Mon Sep 17 00:00:00 2001 From: Jeya R Date: Wed, 23 Sep 2020 20:05:50 +0530 Subject: [PATCH] adsprpc: Move sleepable operations outside spin_lock Use flag to inidcate the allocation of memory to the buffer and move sleepable operation: kzalloc outside spin_lock. Change-Id: Ic5983be3d65a41dfa389f817db8d44a55e068771 Signed-off-by: Jeya R --- drivers/char/adsprpc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/char/adsprpc.c b/drivers/char/adsprpc.c index c2bb4bfdf6c9..6413118edcb3 100644 --- a/drivers/char/adsprpc.c +++ b/drivers/char/adsprpc.c @@ -588,6 +588,8 @@ struct fastrpc_file { /* Identifies the device (MINOR_NUM_DEV / MINOR_NUM_SECURE_DEV) */ int dev_minor; char *debug_buf; + /* Flag to indicate attempt has been made to allocate memory for debug_buf*/ + int debug_buf_alloced_attempted; /* Flag to enable PM wake/relax voting for every remote invoke */ int wake_enable; struct gid_list gidlist; @@ -5313,12 +5315,13 @@ static int fastrpc_set_process_info(struct fastrpc_file *fl) + strlen(strpid) + 1; spin_lock(&fl->hlock); - if (fl->debug_buf) { + if (fl->debug_buf_alloced_attempted) { spin_unlock(&fl->hlock); return err; } - fl->debug_buf = kzalloc(buf_size, GFP_KERNEL); + fl->debug_buf_alloced_attempted = 1; spin_unlock(&fl->hlock); + fl->debug_buf = kzalloc(buf_size, GFP_KERNEL); if (!fl->debug_buf) { err = -ENOMEM;