From e38a5e52d2fb43ced7198e04f286886a8aa5c798 Mon Sep 17 00:00:00 2001 From: weishu Date: Thu, 21 Mar 2024 14:15:11 +0800 Subject: [PATCH] kernel: we should take ownership over fd --- kernel/ksud.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/ksud.c b/kernel/ksud.c index b817e9d3..08ab1575 100644 --- a/kernel/ksud.c +++ b/kernel/ksud.c @@ -388,11 +388,13 @@ int ksu_handle_vfs_read(struct file **file_ptr, char __user **buf_ptr, int ksu_handle_sys_read(unsigned int fd, char __user **buf_ptr, size_t *count_ptr) { - struct file *file = fget_raw(fd); + struct file *file = fget(fd); if (!file) { return 0; } - return ksu_handle_vfs_read(&file, buf_ptr, count_ptr, NULL); + int result = ksu_handle_vfs_read(&file, buf_ptr, count_ptr, NULL); + fput(file); + return result; } static unsigned int volumedown_pressed_count = 0;