Hello, There are several places where the return values of the functions fshelp_map_active_translators, fshelp_set_active, and fshelp_fetch_control are not checked. Additionally, there are a few instances where the return value of fshelp_remove_active_translator is not checked; however, since this function always returns 0, should we even be concerned about it?
Thanks, -- Mikhail Karpov
From fe6aa0c62608a53932f44bd9167a18df3fe1cee6 Mon Sep 17 00:00:00 2001 From: Mikhail Karpov <[email protected]> Date: Thu, 19 Nov 2026 10:55:28 +0700 Subject: [PATCH 2/2] Added checks for libfshelp functions return value in several place --- fatfs/dir.c | 4 +++- libdiskfs/dir-unlink.c | 2 +- libdiskfs/fsys-syncfs.c | 9 +++++++-- libfshelp/fetch-root.c | 6 +++++- libnetfs/fsys-syncfs.c | 8 ++++++-- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/fatfs/dir.c b/fatfs/dir.c index d210bcc..4746188 100644 --- a/fatfs/dir.c +++ b/fatfs/dir.c @@ -751,7 +751,9 @@ diskfs_dirrewrite_hard (struct node *dp, struct node *np, struct dirstat *ds) assert_backtrace (!oldnp->dn_stat.st_nlink); /* Close the file, free the referenced held by clients. */ - fshelp_fetch_control (&oldnp->transbox, &control); + err = fshelp_fetch_control (&oldnp->transbox, &control); + if (err) + return err; if (control) { diff --git a/libdiskfs/dir-unlink.c b/libdiskfs/dir-unlink.c index eaf62f9..3555d9e 100644 --- a/libdiskfs/dir-unlink.c +++ b/libdiskfs/dir-unlink.c @@ -84,7 +84,7 @@ diskfs_S_dir_unlink (struct protid *dircred, diskfs_node_update (np, diskfs_synchronous); if (np->dn_stat.st_nlink == 0) - fshelp_fetch_control (&np->transbox, &control); + err = fshelp_fetch_control (&np->transbox, &control); /* This check is necessary because we might get here on an error while checking the mode on something which happens to be `.'. */ diff --git a/libdiskfs/fsys-syncfs.c b/libdiskfs/fsys-syncfs.c index 1a40fcd..617c472 100644 --- a/libdiskfs/fsys-syncfs.c +++ b/libdiskfs/fsys-syncfs.c @@ -45,6 +45,7 @@ diskfs_S_fsys_syncfs (struct diskfs_control *pi, int children) { struct args args = { wait }; + error_t err = 0; if (!pi) return EOPNOTSUPP; @@ -52,7 +53,10 @@ diskfs_S_fsys_syncfs (struct diskfs_control *pi, pthread_rwlock_rdlock (&diskfs_fsys_lock); if (children) - fshelp_map_active_translators (helper, &args); + err = fshelp_map_active_translators (helper, &args); + + if (err) + goto out; if (diskfs_synchronous) wait = 1; @@ -63,6 +67,7 @@ diskfs_S_fsys_syncfs (struct diskfs_control *pi, diskfs_set_hypermetadata (wait, 0); } + out: pthread_rwlock_unlock (&diskfs_fsys_lock); - return 0; + return err; } diff --git a/libfshelp/fetch-root.c b/libfshelp/fetch-root.c index a7cee33..fcd83d4 100644 --- a/libfshelp/fetch-root.c +++ b/libfshelp/fetch-root.c @@ -195,7 +195,11 @@ fshelp_fetch_root (struct transbox *box, void *cookie, if ((err == MACH_SEND_INVALID_DEST || err == MIG_SERVER_DIED) && control == box->active) - fshelp_set_active (box, MACH_PORT_NULL, 0); + { + error_t err2 = fshelp_set_active (box, MACH_PORT_NULL, 0); + if (err2) + return err2; + } else mach_port_deallocate (mach_task_self (), control); diff --git a/libnetfs/fsys-syncfs.c b/libnetfs/fsys-syncfs.c index 07a69ea..9a19ba7 100644 --- a/libnetfs/fsys-syncfs.c +++ b/libnetfs/fsys-syncfs.c @@ -44,18 +44,22 @@ netfs_S_fsys_syncfs (struct netfs_control *cntl, int children) { struct iouser *cred; - error_t err; + error_t err = 0; struct args args = { wait }; if (! cntl) return EOPNOTSUPP; if (children) - fshelp_map_active_translators (helper, &args); + err = fshelp_map_active_translators (helper, &args); + + if (err) + return err; err = iohelp_create_simple_iouser (&cred, 0, 0); if (err) return err; + err = netfs_attempt_syncfs (cred, wait); iohelp_free_iouser (cred); return err; -- 2.43.0
