From: Lenny Szubowicz Date: Fri, 28 Jun 2013 20:14:11 +0000 (-0400) Subject: efivars: If pstore_register fails, free unneeded pstore buffer X-Git-Tag: firefly_0821_release~3680^2~36^2~41^2~49 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=bb0145e4e0e6f8112464975795850b3ce00c24f7;p=firefly-linux-kernel-4.4.55.git efivars: If pstore_register fails, free unneeded pstore buffer This is patch 3/3 of a patch set that cleans up pstore_register failure paths. If efivars fails to register with pstore, there is no point to keeping the 4 KB buffer around. It's only used by the pstore read/write routines. Signed-off-by: Lenny Szubowicz Reported-by: Naotaka Hamaguchi Signed-off-by: Tony Luck (cherry picked from commit 0d838347f1325cebfe8b9341a4b4c1f407022231) Signed-off-by: Mark Brown --- diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c index c692bb662178..91864ad200ff 100644 --- a/drivers/firmware/efi/efi-pstore.c +++ b/drivers/firmware/efi/efi-pstore.c @@ -235,7 +235,11 @@ static __init int efivars_pstore_init(void) efi_pstore_info.bufsize = 1024; spin_lock_init(&efi_pstore_info.buf_lock); - pstore_register(&efi_pstore_info); + if (pstore_register(&efi_pstore_info)) { + kfree(efi_pstore_info.buf); + efi_pstore_info.buf = NULL; + efi_pstore_info.bufsize = 0; + } return 0; }