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
This commit is contained in:
parent
7898a1f4c4
commit
70d66bcf28
@ -2038,6 +2038,9 @@ kern_cpuset_setdomain(struct thread *td, cpulevel_t level, cpuwhich_t which,
|
||||
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 level, cpuwhich_t which,
|
||||
}
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user