From 9adf75afbef81a8c6cbf04a9312e3396643908f2 Mon Sep 17 00:00:00 2001 From: Hongjin Li Date: Mon, 13 Nov 2023 12:12:30 +0800 Subject: [PATCH] fix: handle fp invalid err Signed-off-by: Hongjin Li --- code_sign/code_sign_elf.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code_sign/code_sign_elf.c b/code_sign/code_sign_elf.c index 674f0e9..ed7acaf 100644 --- a/code_sign/code_sign_elf.c +++ b/code_sign/code_sign_elf.c @@ -173,16 +173,16 @@ int elf_file_enable_fs_verity(struct file *file) } int err = 0; char *real_path = file_path(file, path_buf, PATH_MAX - 1); - if (!real_path) { + if (IS_ERR_OR_NULL(real_path)) { code_sign_log_error("get file path failed"); - err = -EFAULT; + err = -ENOENT; goto release_path_buf_out; } struct file *fp = filp_open(real_path, O_RDONLY, 0); - if (!fp) { + if (IS_ERR(fp)) { code_sign_log_error("filp_open failed"); - err = -EFAULT; + err = PTR_ERR(fp); goto release_path_buf_out; } struct inode *inode = file_inode(fp); -- Gitee