diff --git a/src/afsd/afsd.c b/src/afsd/afsd.c index 5276e5cbe0..c83473b718 100644 --- a/src/afsd/afsd.c +++ b/src/afsd/afsd.c @@ -896,6 +896,7 @@ CreateCacheFile(char *fname, struct stat *statp) if (statp != NULL) { closeResult = fstat(cfd, statp); if (closeResult) { + close(cfd); printf ("%s: Can't stat newly-created AFS cache file '%s' (code %d)\n", rn, fname, errno); @@ -1519,6 +1520,7 @@ BkgHandler(void) char dstName[256]; uspc = calloc(1, sizeof(struct afs_uspc_param)); + opr_Assert(uspc != NULL); memset(srcName, 0, sizeof(srcName)); memset(dstName, 0, sizeof(dstName)); @@ -1538,7 +1540,7 @@ BkgHandler(void) * like a AFS_USPC_SHUTDOWN, in case we're running with an * older kernel module. */ - return; + goto done; } sleep(1); @@ -1549,7 +1551,7 @@ BkgHandler(void) switch (uspc->reqtype) { case AFS_USPC_SHUTDOWN: /* Client is shutting down */ - return; + goto done; case AFS_USPC_NOOP: /* noop */ @@ -1638,6 +1640,9 @@ BkgHandler(void) break; } } + + done: + free(uspc); } #endif @@ -2152,9 +2157,6 @@ CheckOptions(struct cmd_syndesc *as) #ifdef AFS_SUN5_ENV struct stat st; #endif -#ifdef AFS_SGI_ENV - struct sched_param sp; -#endif #ifdef AFS_SGI_VNODE_GLUE if (afs_init_kernel_config(-1) < 0) { @@ -3260,6 +3262,7 @@ fork_syscall_impl(int rx, int wait, const char *rn, int syscall, va_list ap) struct afsd_syscall_args *args; args = malloc(sizeof(*args)); + opr_Assert(args != NULL); afsd_syscall_populate(args, syscall, ap); args->rxpri = rx; args->rn = rn; diff --git a/src/afsd/afsd_fuse.c b/src/afsd/afsd_fuse.c index 6c03476e7c..c666e474f5 100644 --- a/src/afsd/afsd_fuse.c +++ b/src/afsd/afsd_fuse.c @@ -401,6 +401,9 @@ fuafsd_write(const char *path, const char *abuf, size_t len, off_t offset, { int fd, code; char *buf = malloc(len); + if (buf == NULL) { + return -ENOMEM; + } fd = fi->fh; memcpy(buf, abuf, len); diff --git a/src/afsd/afsd_kernel.c b/src/afsd/afsd_kernel.c index ad4e15af07..ce3175af79 100644 --- a/src/afsd/afsd_kernel.c +++ b/src/afsd/afsd_kernel.c @@ -491,6 +491,7 @@ HandleMTab(char *cacheMountDir) } dir = strdup(cacheMountDir); + opr_Assert(dir != NULL); /* trim trailing slashes; don't look at dir[0] in case we are somehow * just "/" */ @@ -606,6 +607,7 @@ afsd_mount_afs(const char *rn, const char *cacheMountDir) } mountDir = strdup(cacheMountDir); + opr_Assert(mountDir != NULL); HandleMTab(mountDir); free(mountDir); }