From e4ebea27b2f339706da76a3e79cb63ea9ed97c38 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sat, 11 May 2024 20:41:00 +0200 Subject: kernel: fix null dereference when delegating an nonexistent handle --- src/kernel/vfs/request.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/kernel/vfs') diff --git a/src/kernel/vfs/request.c b/src/kernel/vfs/request.c index 0c763b3..e3f0316 100644 --- a/src/kernel/vfs/request.c +++ b/src/kernel/vfs/request.c @@ -60,9 +60,10 @@ void vfsreq_finish(VfsReq *req, char __user *stored, long ret, /* delegating - moving a handle to the caller */ assert(handler); h = hs_take(handler->hs, ret); - // TODO!!! no null check - h->readable = h->readable && OPEN_READABLE(req->flags); - h->writeable = h->writeable && OPEN_WRITEABLE(req->flags); + if (h) { + h->readable = h->readable && OPEN_READABLE(req->flags); + h->writeable = h->writeable && OPEN_WRITEABLE(req->flags); + } } if (h) { -- cgit v1.2.3