Re: [patch 4/7] BSD Secure Levels: memory alloc failure check

From: Alexey Dobriyan
Date: Tue May 17 2005 - 12:28:34 EST


On Tuesday 17 May 2005 19:27, Michael Halcrow wrote:
> It adds a check for a memory allocation failure
> condition.

And leaks tfm if such failure occurs.

> --- linux-2.6.12-rc4-mm2-seclvl.orig/security/seclvl.c
> +++ linux-2.6.12-rc4-mm2-seclvl/security/seclvl.c

> static int
> plaintext_to_sha1(unsigned char *hash, const char *plaintext, int len)
> {

tfm = crypto_alloc_tfm("sha1", 0);
if (tfm == NULL) {
seclvl_printk(0, KERN_ERR, "Failed to load transform for SHA1\n");
return -ENOSYS;
> }
> // Just get a new page; don't play around with page boundaries
> // and scatterlists.
> - pgVirtAddr = (char *)__get_free_page(GFP_KERNEL);
> - sg[0].page = virt_to_page(pgVirtAddr);
> + pg_virt_addr = (char *)__get_free_page(GFP_KERNEL);
> + if (!pg_virt_addr) {
> + seclvl_printk(0, KERN_ERR "%s: Out of memory\n", __FUNCTION__);
> + return -ENOMEM;
> + }
-
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/