ref: a2e593332e9e24358a2853bcb74a804ddabc0658
parent: d181a7286ee394a8a7b6ca7148904e5827ecabcb
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Dec 1 00:52:56 EST 2023
fs: fix getmount poperror balance
--- a/fs.c
+++ b/fs.c
@@ -453,18 +453,21 @@
ainc(&fs->snapmnt->ref);
return fs->snapmnt;
}
+
lock(&fs->mountlk);
- for(mnt = fs->mounts; mnt != nil; mnt = mnt->next)
+ for(mnt = fs->mounts; mnt != nil; mnt = mnt->next){
if(strcmp(name, mnt->name) == 0){
ainc(&mnt->ref);
goto Out;
}
+ }
+
if((mnt = mallocz(sizeof(*mnt), 1)) == nil)
- goto Out;
+ error(Enomem);
if(waserror()){
unlock(&fs->mountlk);
free(mnt);
- return nil;
+ nexterror();
}
mnt->ref = 1;
snprint(mnt->name, sizeof(mnt->name), "%s", name);
@@ -474,10 +477,10 @@
mnt->root = t;
mnt->next = fs->mounts;
fs->mounts = mnt;
+ poperror();
Out:
unlock(&fs->mountlk);
- poperror();
return mnt;
}
@@ -1014,6 +1017,7 @@
r.qid = d.qid;
respond(m, &r);
poperror();
+
Err: clunkdent(de);
clunkmount(mnt);