diff mbox

[2/7] pstore/ram: Fix error handling during przs allocation

Message ID 1340072156-6225-2-git-send-email-anton.vorontsov@linaro.org
State Accepted
Commit 90b58d96907e0a45555429c0d3a79c85cea4b9fc
Headers show

Commit Message

Anton Vorontsov June 19, 2012, 2:15 a.m. UTC
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>
---
 fs/pstore/ram.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kees Cook June 19, 2012, 6:40 p.m. UTC | #1
On Mon, Jun 18, 2012 at 7:15 PM, Anton Vorontsov
<anton.vorontsov@linaro.org> wrote:
> 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>
diff mbox

Patch

diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 0b36e91..58b93fb 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);
 }