svn commit: r334240 - head/sys/kern
Eric van Gyzen
vangyzen at FreeBSD.org
Sat May 26 14:23:12 UTC 2018
Author: vangyzen
Date: Sat May 26 14:23:11 2018
New Revision: 334240
URL: https://svnweb.freebsd.org/changeset/base/334240
Log:
kern_cpuset: fix small leak on error path
The "mask" was leaked on some error paths.
Reported by: Coverity
CID: 1384683
Sponsored by: Dell EMC
Modified:
head/sys/kern/kern_cpuset.c
Modified: head/sys/kern/kern_cpuset.c
==============================================================================
--- head/sys/kern/kern_cpuset.c Sat May 26 14:14:56 2018 (r334239)
+++ head/sys/kern/kern_cpuset.c Sat May 26 14:23:11 2018 (r334240)
@@ -2038,6 +2038,9 @@ kern_cpuset_setdomain(struct thread *td, cpulevel_t le
if (domainsetsize < sizeof(domainset_t) ||
domainsetsize > DOMAINSET_MAXSIZE / NBBY)
return (ERANGE);
+ if (policy <= DOMAINSET_POLICY_INVALID ||
+ policy > DOMAINSET_POLICY_MAX)
+ return (EINVAL);
/* In Capability mode, you can only set your own CPU set. */
if (IN_CAPABILITY_MODE(td)) {
if (level != CPU_LEVEL_WHICH)
@@ -2071,15 +2074,14 @@ kern_cpuset_setdomain(struct thread *td, cpulevel_t le
}
DOMAINSET_COPY(mask, &domain.ds_mask);
domain.ds_policy = policy;
- if (policy <= DOMAINSET_POLICY_INVALID ||
- policy > DOMAINSET_POLICY_MAX)
- return (EINVAL);
/* Translate preferred policy into a mask and fallback. */
if (policy == DOMAINSET_POLICY_PREFER) {
/* Only support a single preferred domain. */
- if (DOMAINSET_COUNT(&domain.ds_mask) != 1)
- return (EINVAL);
+ if (DOMAINSET_COUNT(&domain.ds_mask) != 1) {
+ error = EINVAL;
+ goto out;
+ }
domain.ds_prefer = DOMAINSET_FFS(&domain.ds_mask) - 1;
/* This will be constrained by domainset_shadow(). */
DOMAINSET_FILL(&domain.ds_mask);
More information about the svn-src-head
mailing list