Re: SV: PATCH: Arla CVS Current on Linux 2.6.24-2.6.35-rc1

Bo Brantén <[email protected]> Sun, 11 Jul 2010 18:29:38 +0200 (CEST)
Newsgroups gmane.comp.file-systems.arla.general
Message-ID <[email protected]>
On Tue, 29 Jun 2010, Tomas Olsson wrote:

> We may be leaking group_info references in nnpfs_get_pag_group() and store_pag().

Yes, the reference count is decremented with put_group_info() but it is 
two possible ways to fix it, I think the second one is the most correct:

nnpfs_get_pag_group(void)
{
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
     struct group_info *gi = current->group_info;
     nnpfs_pag_t ret = current->uid;
#else
     struct group_info *gi = get_current_groups();
     nnpfs_pag_t ret = current_uid();
#endif
     int i;

     get_group_info(gi);

     i = find_pag(gi);
     if (i != NNPFS_PAG_NOTFOUND)
         ret = GROUP_AT(gi, i);

     put_group_info(gi);
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28)
     put_group_info(gi);
#endif

     NNPFSDEB(XDEBSYS, ("nnpfs_get_pag_group: returning %u\n", ret));
     return ret;
}

nnpfs_get_pag_group(void)
{
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
     struct group_info *gi = current->group_info;
     nnpfs_pag_t ret = current->uid;
#else
     struct group_info *gi = get_current_groups();
     nnpfs_pag_t ret = current_uid();
#endif
     int i;

#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,28)
     get_group_info(gi);
#endif

     i = find_pag(gi);
     if (i != NNPFS_PAG_NOTFOUND)
         ret = GROUP_AT(gi, i);

     put_group_info(gi);

     NNPFSDEB(XDEBSYS, ("nnpfs_get_pag_group: returning %u\n", ret));
     return ret;
}

Bo Branten