Переглянути джерело

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 <[email protected]>
Signed-off-by: Vamsi Krishna Gattupalli <[email protected]>
Signed-off-by: Himateja Reddy <[email protected]>
Himateja Reddy 2 роки тому
батько
коміт
6554e75e39
1 змінених файлів з 11 додано та 0 видалено
  1. 11 0
      dsp/adsprpc.c

+ 11 - 0
dsp/adsprpc.c

@@ -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;