From d16bfd005a6dae78df2df3ad55cf21e0716dfae9 Mon Sep 17 00:00:00 2001 From: wangchen <253227059@qq.com> Date: Fri, 20 Aug 2021 16:41:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=20A=E6=A0=B8=E5=91=8A=E8=AD=A6=E6=B6=88?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【背景】定期A核代码消除。 【修改方案】 1,根据工具扫描结果,对代码告警进行更改 【影响】 对现有的产品编译不会有影响。 re #I46KF6 Signed-off-by: wangchen <253227059@qq.com> --- fs/proc/os_adapt/fd_proc.c | 2 +- fs/vfs/operation/vfs_cloexec.c | 5 ++++- fs/vfs/operation/vfs_force_umount.c | 8 ++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fs/proc/os_adapt/fd_proc.c b/fs/proc/os_adapt/fd_proc.c index b0ff2ba4..d357227a 100644 --- a/fs/proc/os_adapt/fd_proc.c +++ b/fs/proc/os_adapt/fd_proc.c @@ -75,7 +75,7 @@ static void FillFdInfo(struct SeqBuf *seqBuf, struct filelist *fileList, unsigne } if (hasPrivilege) { - (void)LosBufPrintf(seqBuf, "%u\t%d\t%6d <%d>\t%s\n", pid, fd, sysFd, filp->f_refcount, name); + (void)LosBufPrintf(seqBuf, "%u\t%d\t%6d <%d>\t%s\n", pid, fd, sysFd, filp ? filp->f_refcount : 1, name); } else { (void)LosBufPrintf(seqBuf, "%u\t%d\t%s\n", pid, fd, name); } diff --git a/fs/vfs/operation/vfs_cloexec.c b/fs/vfs/operation/vfs_cloexec.c index 0943aa7a..f69edecb 100644 --- a/fs/vfs/operation/vfs_cloexec.c +++ b/fs/vfs/operation/vfs_cloexec.c @@ -50,7 +50,10 @@ void CloseOnExec(struct files_struct *files) if (FD_ISSET(i, files->fdt->proc_fds) && FD_ISSET(i, files->fdt->cloexec_fds)) { sysFd = DisassociateProcessFd(i); - close(sysFd); + if (sysFd >= 0) { + close(sysFd); + } + FreeProcessFd(i); } } diff --git a/fs/vfs/operation/vfs_force_umount.c b/fs/vfs/operation/vfs_force_umount.c index 609bee39..5d0d385a 100644 --- a/fs/vfs/operation/vfs_force_umount.c +++ b/fs/vfs/operation/vfs_force_umount.c @@ -265,6 +265,10 @@ static struct Mount* GetDevMountPoint(struct Vnode *dev) { struct Mount *mnt = NULL; LIST_HEAD *mntList = GetMountList(); + if (mntList == NULL) { + return NULL; + } + LOS_DL_LIST_FOR_EACH_ENTRY(mnt, mntList, struct Mount, mountList) { if (mnt->vnodeDev == dev) { return mnt; @@ -302,7 +306,7 @@ static void FileDisableAndClean(struct Mount *mnt) { struct filelist *flist = &tg_filelist; struct file *filep = NULL; - const struct file_operations_vfs *originOps; + const struct file_operations_vfs *originOps = NULL; for (int i = 3; i < CONFIG_NFILE_DESCRIPTORS; i++) { if (!get_bit(i)) { @@ -355,7 +359,7 @@ static void VnodeTryFreeAll(struct Mount *mount) int ForceUmountDev(struct Vnode *dev) { int ret; - struct Vnode *origin; + struct Vnode *origin = NULL; struct filelist *flist = &tg_filelist; if (dev == NULL) { return -EINVAL;