Skip to content

Commit

Permalink
pstore/ram: Fix error handling during przs allocation
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Kees Cook <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Anton Vorontsov authored and gregkh committed Jun 20, 2012
1 parent 924d371 commit 90b58d9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/pstore/ram.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 90b58d9

Please sign in to comment.