pstore/ram: Fix error handling during przs allocation
authorAnton Vorontsov <anton.vorontsov@linaro.org>
Tue, 19 Jun 2012 02:15:51 +0000 (19:15 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Jun 2012 23:15:22 +0000 (16:15 -0700)
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>
fs/pstore/ram.c

index 0b36e91978e6f05745449ac5d09e84ac6e23bf65..58b93fbd117e0a032b8b815919c06b058746a897 100644 (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);
 }