Re: [PATCH] security/integrity/ima/ima_iint.c: Remove goto out int ima_inode_alloc()

From: Xiaotian Feng
Date: Mon Feb 08 2010 - 02:08:48 EST


On Mon, Feb 8, 2010 at 2:57 PM, wzt wzt <wzt.wzt@xxxxxxxxx> wrote:
> Signed-off-by: wzt <zhitong.wangzt@xxxxxxxxxxxxxxx>
>
> diff --git a/security/integrity/ima/ima_iint.c
> b/security/integrity/ima/ima_iint.c
> index 0d83edc..4e2df22 100644
> --- a/security/integrity/ima/ima_iint.c
> +++ b/security/integrity/ima/ima_iint.c
> @@ -57,18 +57,17 @@ int ima_inode_alloc(struct inode *inode)
> Â Â Â Â Â Â Â Âreturn -ENOMEM;
>
> Â Â Â Ârc = radix_tree_preload(GFP_NOFS);
> - Â Â Â if (rc < 0)
> - Â Â Â Â Â Â Â goto out;
> + Â Â Â if (rc < 0) {
> + Â Â Â Â Â Â Â kmem_cache_free(iint_cache, iint);
> + Â Â Â Â Â Â Â radix_tree_preload_end();
> + Â Â Â Â Â Â Â return rc;
> + Â Â Â }
>
> Â Â Â Âspin_lock(&ima_iint_lock);
> Â Â Â Ârc = radix_tree_insert(&ima_iint_store, (unsigned long)inode, iint);
> Â Â Â Âspin_unlock(&ima_iint_lock);
> -out:
> - Â Â Â if (rc < 0)
> - Â Â Â Â Â Â Â kmem_cache_free(iint_cache, iint);

So if radix_tree_insert failed, the memory will be leaked.
This patch doesn't fix anything but introduces new bug....

>
> Â Â Â Âradix_tree_preload_end();
> -
> Â Â Â Âreturn rc;
> Â}
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
> Please read the FAQ at Âhttp://www.tux.org/lkml/
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/