9ns: make kstrdup() actually atomic
[akaros.git] / kern / src / ns / chan.c
index 0012d72..af83d1b 100644 (file)
@@ -118,8 +118,8 @@ void kstrdup(char **p, char *s)
                        panic("kstrdup: no memory");
        }
        memmove(t, s, n);
-       prev = *p;
-       *p = t;
+
+       prev = atomic_swap_ptr((void**)p, t);
        kfree(prev);
 }