msm: ADSPRPC: Prevent mapping refcount for persistent mapping from going bad

Mapping refcount goes to negative value when internal invoke fails. This
prevents in hyp assigning the memory back to dsp.

Change-Id: I3b0f4a80e8fd1cde43e5b6fe94030258eb01ead1
Acked-by: Abhinav Parihar <parihar@qti.qualcomm.com>
Signed-off-by: Vamsi Krishna Gattupalli <quic_vgattupa@quicinc.com>
Signed-off-by: Himateja Reddy <quic_hmreddy@quicinc.com>
This commit is contained in:
Himateja Reddy
2023-02-03 07:55:44 -08:00
committed by Gerrit - the friendly Code Review server
parent bfd12fbf25
commit 6554e75e39

View File

@@ -1049,6 +1049,12 @@ static inline bool fastrpc_get_persistent_map(size_t len, struct fastrpc_mmap **
map->is_persistent && !map->in_use) {
*pers_map = map;
map->in_use = true;
/*
* Incrementing map reference count when getting
* the map to avoid negative reference count when
* freeing the map.
*/
map->refs++;
found = true;
break;
}
@@ -4741,6 +4747,11 @@ static int fastrpc_mmap_remove_ssr(struct fastrpc_file *fl, int locked)
}
spin_lock_irqsave(&me->hlock, irq_flags);
map->in_use = false;
/*
* decrementing refcount for persistent mappings
* as incrementing it in fastrpc_get_persistent_map
*/
map->refs--;
}
if (map->is_persistent) {
match = NULL;