@@ -702,19 +702,23 @@ EXPORT_SYMBOL(l2_sram_free);
int sram_free_with_lsl(const void *addr)
{
- struct sram_list_struct *lsl, **tmp;
+ struct sram_list_struct *lsl = NULL, **tmp;
struct mm_struct *mm = current->mm;
+ down_write(&mm->mmap_sem);
for (tmp = &mm->context.sram_list; *tmp; tmp = &(*tmp)->next)
- if ((*tmp)->addr == addr)
- goto found;
- return -1;
-found:
- lsl = *tmp;
+ if ((*tmp)->addr == addr) {
+ lsl = *tmp;
+ *tmp = lsl->next;
+ break;
+ }
+ up_write(&mm->mmap_sem);
+
+ if (!lsl)
+ return -1;
+
sram_free(addr);
- *tmp = lsl->next;
kfree(lsl);
-
return 0;
}
EXPORT_SYMBOL(sram_free_with_lsl);
@@ -749,10 +753,14 @@ void *sram_alloc_with_lsl(size_t size, u
kfree(lsl);
return NULL;
}
+
+ down_write(&mm->mmap_sem);
lsl->addr = addr;
lsl->length = size;
lsl->next = mm->context.sram_list;
mm->context.sram_list = lsl;
+ up_write(&mm->mmap_sem);
+
return addr;
}
EXPORT_SYMBOL(sram_alloc_with_lsl);