Fix splat-cred.c cred usage
No need to crhold current_cred(), fix possible leak in splat_cred_test2 Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Chunwei Chen <david.chen@osnexus.com> Closes #556
This commit is contained in:
parent
9ba3c01923
commit
87063d7dc3
|
@ -53,18 +53,18 @@ splat_cred_test1(struct file *file, void *arg)
|
||||||
uid_t uid, ruid, suid;
|
uid_t uid, ruid, suid;
|
||||||
gid_t gid, rgid, sgid, *groups;
|
gid_t gid, rgid, sgid, *groups;
|
||||||
int ngroups, i, count = 0;
|
int ngroups, i, count = 0;
|
||||||
|
cred_t *cr = CRED();
|
||||||
|
|
||||||
uid = crgetuid(CRED());
|
uid = crgetuid(cr);
|
||||||
ruid = crgetruid(CRED());
|
ruid = crgetruid(cr);
|
||||||
suid = crgetsuid(CRED());
|
suid = crgetsuid(cr);
|
||||||
|
|
||||||
gid = crgetgid(CRED());
|
gid = crgetgid(cr);
|
||||||
rgid = crgetrgid(CRED());
|
rgid = crgetrgid(cr);
|
||||||
sgid = crgetsgid(CRED());
|
sgid = crgetsgid(cr);
|
||||||
|
|
||||||
crhold(CRED());
|
ngroups = crgetngroups(cr);
|
||||||
ngroups = crgetngroups(CRED());
|
groups = crgetgroups(cr);
|
||||||
groups = crgetgroups(CRED());
|
|
||||||
|
|
||||||
memset(str, 0, GROUP_STR_SIZE);
|
memset(str, 0, GROUP_STR_SIZE);
|
||||||
for (i = 0; i < ngroups; i++) {
|
for (i = 0; i < ngroups; i++) {
|
||||||
|
@ -78,8 +78,6 @@ splat_cred_test1(struct file *file, void *arg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
crfree(CRED());
|
|
||||||
|
|
||||||
splat_vprint(file, SPLAT_CRED_TEST1_NAME,
|
splat_vprint(file, SPLAT_CRED_TEST1_NAME,
|
||||||
"uid: %d ruid: %d suid: %d "
|
"uid: %d ruid: %d suid: %d "
|
||||||
"gid: %d rgid: %d sgid: %d\n",
|
"gid: %d rgid: %d sgid: %d\n",
|
||||||
|
@ -114,6 +112,8 @@ splat_cred_test2(struct file *file, void *arg)
|
||||||
gid_t gid, rgid, sgid, *groups;
|
gid_t gid, rgid, sgid, *groups;
|
||||||
int ngroups, i, count = 0;
|
int ngroups, i, count = 0;
|
||||||
|
|
||||||
|
crhold(kcred);
|
||||||
|
|
||||||
uid = crgetuid(kcred);
|
uid = crgetuid(kcred);
|
||||||
ruid = crgetruid(kcred);
|
ruid = crgetruid(kcred);
|
||||||
suid = crgetsuid(kcred);
|
suid = crgetsuid(kcred);
|
||||||
|
@ -122,7 +122,6 @@ splat_cred_test2(struct file *file, void *arg)
|
||||||
rgid = crgetrgid(kcred);
|
rgid = crgetrgid(kcred);
|
||||||
sgid = crgetsgid(kcred);
|
sgid = crgetsgid(kcred);
|
||||||
|
|
||||||
crhold(kcred);
|
|
||||||
ngroups = crgetngroups(kcred);
|
ngroups = crgetngroups(kcred);
|
||||||
groups = crgetgroups(kcred);
|
groups = crgetgroups(kcred);
|
||||||
|
|
||||||
|
@ -134,6 +133,7 @@ splat_cred_test2(struct file *file, void *arg)
|
||||||
splat_vprint(file, SPLAT_CRED_TEST2_NAME,
|
splat_vprint(file, SPLAT_CRED_TEST2_NAME,
|
||||||
"Failed too many group entries for temp "
|
"Failed too many group entries for temp "
|
||||||
"buffer: %d, %s\n", ngroups, str);
|
"buffer: %d, %s\n", ngroups, str);
|
||||||
|
crfree(kcred);
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue