Kernel - add missing crfree() calls to two linux emulation functions
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 1 Sep 2009 18:18:11 +0000 (11:18 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 1 Sep 2009 18:18:11 +0000 (11:18 -0700)
sys/emulation/linux/linux_misc.c
sys/emulation/linux/linux_uid16.c

index 12f2e39..5e1e2ab 100644 (file)
@@ -982,8 +982,10 @@ sys_linux_setgroups(struct linux_setgroups_args *args)
        if (ngrp > 0) {
                error = copyin((caddr_t)args->grouplist, linux_gidset,
                               ngrp * sizeof(l_gid_t));
-               if (error)
+               if (error) {
+                       crfree(newcred);
                        return (error);
+               }
 
                newcred->cr_ngroups = ngrp + 1;
 
index 2d495ea..35054b6 100644 (file)
@@ -131,9 +131,11 @@ sys_linux_setgroups16(struct linux_setgroups16_args *args)
        newcred = crdup(oldcred);
        if (ngrp > 0) {
                error = copyin((caddr_t)args->gidset, linux_gidset,
-                   ngrp * sizeof(l_gid16_t));
-               if (error)
+                              ngrp * sizeof(l_gid16_t));
+               if (error) {
+                       crfree(newcred);
                        return (error);
+               }
 
                newcred->cr_ngroups = ngrp + 1;
 
@@ -143,9 +145,9 @@ sys_linux_setgroups16(struct linux_setgroups16_args *args)
                        bsd_gidset[ngrp + 1] = linux_gidset[ngrp];
                        ngrp--;
                }
-       }
-       else
+       } else {
                newcred->cr_ngroups = 1;
+       }
 
        setsugid();
        p->p_ucred = newcred;