From: Anton Vorontsov Date: Tue, 19 Jun 2012 02:15:51 +0000 (-0700) Subject: pstore/ram: Fix error handling during przs allocation X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=90b58d96907e0a45555429c0d3a79c85cea4b9fc;p=linux-beck.git pstore/ram: Fix error handling during przs allocation persistent_ram_new() returns ERR_PTR() value on errors, so during freeing of the przs we should check for both NULL and IS_ERR() entries, otherwise bad things will happen. Signed-off-by: Anton Vorontsov Acked-by: Kees Cook Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c index 0b36e91978e6..58b93fbd117e 100644 --- a/fs/pstore/ram.c +++ b/fs/pstore/ram.c @@ -260,7 +260,7 @@ static void ramoops_free_przs(struct ramoops_context *cxt) if (!cxt->przs) return; - for (i = 0; cxt->przs[i]; i++) + for (i = 0; !IS_ERR_OR_NULL(cxt->przs[i]); i++) persistent_ram_free(cxt->przs[i]); kfree(cxt->przs); }