efivars: If pstore_register fails, free unneeded pstore buffer
authorLenny Szubowicz <lszubowi@redhat.com>
Fri, 28 Jun 2013 20:14:11 +0000 (16:14 -0400)
committerTony Luck <tony.luck@intel.com>
Fri, 28 Jun 2013 22:23:24 +0000 (15:23 -0700)
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 <lszubowi@redhat.com>
Reported-by: Naotaka Hamaguchi <n.hamaguchi@jp.fujitsu.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
drivers/firmware/efi/efi-pstore.c

index c692bb6621783b81a5d1cff34a77b2c9af301a9d..91864ad200fffbe44cbc7e2c13d09c3e0d174ece 100644 (file)
@@ -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;
 }