aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firmware/efi/efi-pstore.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/firmware/efi/efi-pstore.c')
-rw-r--r--drivers/firmware/efi/efi-pstore.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
index 202d2c85ba2e..91864ad200ff 100644
--- a/drivers/firmware/efi/efi-pstore.c
+++ b/drivers/firmware/efi/efi-pstore.c
@@ -79,10 +79,9 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data)
79 &entry->var.DataSize, entry->var.Data); 79 &entry->var.DataSize, entry->var.Data);
80 size = entry->var.DataSize; 80 size = entry->var.DataSize;
81 81
82 *cb_data->buf = kmalloc(size, GFP_KERNEL); 82 *cb_data->buf = kmemdup(entry->var.Data, size, GFP_KERNEL);
83 if (*cb_data->buf == NULL) 83 if (*cb_data->buf == NULL)
84 return -ENOMEM; 84 return -ENOMEM;
85 memcpy(*cb_data->buf, entry->var.Data, size);
86 return size; 85 return size;
87} 86}
88 87
@@ -236,7 +235,11 @@ static __init int efivars_pstore_init(void)
236 efi_pstore_info.bufsize = 1024; 235 efi_pstore_info.bufsize = 1024;
237 spin_lock_init(&efi_pstore_info.buf_lock); 236 spin_lock_init(&efi_pstore_info.buf_lock);
238 237
239 pstore_register(&efi_pstore_info); 238 if (pstore_register(&efi_pstore_info)) {
239 kfree(efi_pstore_info.buf);
240 efi_pstore_info.buf = NULL;
241 efi_pstore_info.bufsize = 0;
242 }
240 243
241 return 0; 244 return 0;
242} 245}