[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH] lib/vfscore: fix null pointer dereference



fhold(fp) is called before checking for !fp, leading to null pointer
dereference if the allocation can't be satisfied. Make sure to check
for !fp before doing anything with this pointer.

Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@xxxxxxxxx>
---
 lib/vfscore/syscalls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/vfscore/syscalls.c b/lib/vfscore/syscalls.c
index 11813db..9b5a6bd 100644
--- a/lib/vfscore/syscalls.c
+++ b/lib/vfscore/syscalls.c
@@ -198,11 +198,11 @@ sys_open(char *path, int flags, mode_t mode, struct 
vfscore_file **fpp)
        }
 
        fp = calloc(sizeof(struct vfscore_file), 1);
-       fhold(fp);
        if (!fp) {
            error = ENOMEM;
            goto out_vn_unlock;
        }
+       fhold(fp);
        fp->f_flags = flags;
 
        // OSv was using a intrusive_ptr which was increasing the refcount
-- 
2.24.1

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.