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 <anton.vorontsov@linaro.org>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Anton Vorontsov 2012-06-18 19:15:51 -07:00 committed by Greg Kroah-Hartman
parent 924d37118f
commit 90b58d9690

View file

@ -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);
}