]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE12-linux-osi-alloc-up-alloc-sem-while-alloc-to-avoid-deadlock-against-glock...
authorDerrick Brashear <shadow@dementia.org>
Tue, 2 Apr 2002 03:11:41 +0000 (03:11 +0000)
committerDerrick Brashear <shadow@dementia.org>
Tue, 2 Apr 2002 03:11:41 +0000 (03:11 +0000)
Based on report from David Howells of RedHat (via Guy Streeter)

(cherry picked from commit f6525247abd62427a05806608a6b58999cfe1a1a)

src/afs/LINUX/osi_alloc.c

index 46ebc4b54bc1188758eb196df153343c3154dd5a..154fce51f6e924a2070a86b2c34c538c713ec812 100644 (file)
@@ -290,7 +290,9 @@ void *osi_linux_alloc(unsigned int asize)
        allocator_init = 1; /* initialization complete */
     }
 
+    up(&afs_linux_alloc_sem);
     new = linux_alloc(asize); /* get a chunk of memory of size asize */
+    down(&afs_linux_alloc_sem);
     if (!new) {
        printf("afs_osi_Alloc: Can't vmalloc %d bytes.\n", asize);
        goto error;
@@ -320,8 +322,11 @@ void *osi_linux_alloc(unsigned int asize)
     return MEMADDR(new);
 
   free_error:
-    if (new)
-        linux_free(new);
+    if (new) {
+       up(&afs_linux_alloc_sem);
+       linux_free(new);
+       down(&afs_linux_alloc_sem);
+    }
     new = NULL;
     goto error;