diff options
Diffstat (limited to 'arch/x86/power/hibernate_64.c')
-rw-r--r-- | arch/x86/power/hibernate_64.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/arch/x86/power/hibernate_64.c b/arch/x86/power/hibernate_64.c index 67ccf64c8bd8..f8e3b668d20b 100644 --- a/arch/x86/power/hibernate_64.c +++ b/arch/x86/power/hibernate_64.c | |||
@@ -233,29 +233,35 @@ struct restore_data_record { | |||
233 | */ | 233 | */ |
234 | static int get_e820_md5(struct e820_table *table, void *buf) | 234 | static int get_e820_md5(struct e820_table *table, void *buf) |
235 | { | 235 | { |
236 | struct scatterlist sg; | 236 | struct crypto_shash *tfm; |
237 | struct crypto_ahash *tfm; | 237 | struct shash_desc *desc; |
238 | int size; | 238 | int size; |
239 | int ret = 0; | 239 | int ret = 0; |
240 | 240 | ||
241 | tfm = crypto_alloc_ahash("md5", 0, CRYPTO_ALG_ASYNC); | 241 | tfm = crypto_alloc_shash("md5", 0, 0); |
242 | if (IS_ERR(tfm)) | 242 | if (IS_ERR(tfm)) |
243 | return -ENOMEM; | 243 | return -ENOMEM; |
244 | 244 | ||
245 | { | 245 | desc = kmalloc(sizeof(struct shash_desc) + crypto_shash_descsize(tfm), |
246 | AHASH_REQUEST_ON_STACK(req, tfm); | 246 | GFP_KERNEL); |
247 | size = offsetof(struct e820_table, entries) + sizeof(struct e820_entry) * table->nr_entries; | 247 | if (!desc) { |
248 | ahash_request_set_tfm(req, tfm); | 248 | ret = -ENOMEM; |
249 | sg_init_one(&sg, (u8 *)table, size); | 249 | goto free_tfm; |
250 | ahash_request_set_callback(req, 0, NULL, NULL); | ||
251 | ahash_request_set_crypt(req, &sg, buf, size); | ||
252 | |||
253 | if (crypto_ahash_digest(req)) | ||
254 | ret = -EINVAL; | ||
255 | ahash_request_zero(req); | ||
256 | } | 250 | } |
257 | crypto_free_ahash(tfm); | ||
258 | 251 | ||
252 | desc->tfm = tfm; | ||
253 | desc->flags = 0; | ||
254 | |||
255 | size = offsetof(struct e820_table, entries) + | ||
256 | sizeof(struct e820_entry) * table->nr_entries; | ||
257 | |||
258 | if (crypto_shash_digest(desc, (u8 *)table, size, buf)) | ||
259 | ret = -EINVAL; | ||
260 | |||
261 | kzfree(desc); | ||
262 | |||
263 | free_tfm: | ||
264 | crypto_free_shash(tfm); | ||
259 | return ret; | 265 | return ret; |
260 | } | 266 | } |
261 | 267 | ||