diff options
author | Kees Cook <keescook@chromium.org> | 2022-10-11 13:01:11 -0700 |
---|---|---|
committer | Kees Cook <keescook@chromium.org> | 2022-10-19 09:25:39 -0700 |
commit | 06b4e09aab6c1ae6b3991a729d2fcb31e358e7f3 (patch) | |
tree | 5b8a38369f5f92974adccae8b10dbb5fd10f8508 /fs/pstore/ram_core.c | |
parent | 8bd4da0f0626ae9a82099d3d99cd6efd4355879b (diff) |
pstore/ram: Set freed addresses to NULL
For good measure, set all the freed addresses to NULL when managing
przs.
Cc: Anton Vorontsov <anton@enomsg.org>
Cc: Colin Cross <ccross@android.com>
Cc: Tony Luck <tony.luck@intel.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-and-tested-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
Link: https://lore.kernel.org/r/20221011200112.731334-5-keescook@chromium.org
Diffstat (limited to 'fs/pstore/ram_core.c')
-rw-r--r-- | fs/pstore/ram_core.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/fs/pstore/ram_core.c b/fs/pstore/ram_core.c index 9e1047f4316d..97dde525150a 100644 --- a/fs/pstore/ram_core.c +++ b/fs/pstore/ram_core.c @@ -544,8 +544,14 @@ static int persistent_ram_post_init(struct persistent_ram_zone *prz, u32 sig, return 0; } -void persistent_ram_free(struct persistent_ram_zone *prz) +void persistent_ram_free(struct persistent_ram_zone **_prz) { + struct persistent_ram_zone *prz; + + if (!_prz) + return; + + prz = *_prz; if (!prz) return; @@ -569,6 +575,7 @@ void persistent_ram_free(struct persistent_ram_zone *prz) persistent_ram_free_old(prz); kfree(prz->label); kfree(prz); + *_prz = NULL; } struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size, @@ -605,6 +612,6 @@ struct persistent_ram_zone *persistent_ram_new(phys_addr_t start, size_t size, return prz; err: - persistent_ram_free(prz); + persistent_ram_free(&prz); return ERR_PTR(ret); } |