Commit 9437e393 authored by Cai Huoqing's avatar Cai Huoqing Committed by Rafael J. Wysocki

PM: hibernate: swap: Use vzalloc() and kzalloc()

Replace vmalloc()/memset() with vzalloc() and kmalloc()/memset() with
kzalloc() to simplify the code.
Signed-off-by: default avatarCai Huoqing <caihuoqing@baidu.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 01de5fcd
...@@ -705,22 +705,19 @@ static int save_image_lzo(struct swap_map_handle *handle, ...@@ -705,22 +705,19 @@ static int save_image_lzo(struct swap_map_handle *handle,
goto out_clean; goto out_clean;
} }
data = vmalloc(array_size(nr_threads, sizeof(*data))); data = vzalloc(array_size(nr_threads, sizeof(*data)));
if (!data) { if (!data) {
pr_err("Failed to allocate LZO data\n"); pr_err("Failed to allocate LZO data\n");
ret = -ENOMEM; ret = -ENOMEM;
goto out_clean; goto out_clean;
} }
for (thr = 0; thr < nr_threads; thr++)
memset(&data[thr], 0, offsetof(struct cmp_data, go));
crc = kmalloc(sizeof(*crc), GFP_KERNEL); crc = kzalloc(sizeof(*crc), GFP_KERNEL);
if (!crc) { if (!crc) {
pr_err("Failed to allocate crc\n"); pr_err("Failed to allocate crc\n");
ret = -ENOMEM; ret = -ENOMEM;
goto out_clean; goto out_clean;
} }
memset(crc, 0, offsetof(struct crc_data, go));
/* /*
* Start the compression threads. * Start the compression threads.
...@@ -1198,22 +1195,19 @@ static int load_image_lzo(struct swap_map_handle *handle, ...@@ -1198,22 +1195,19 @@ static int load_image_lzo(struct swap_map_handle *handle,
goto out_clean; goto out_clean;
} }
data = vmalloc(array_size(nr_threads, sizeof(*data))); data = vzalloc(array_size(nr_threads, sizeof(*data)));
if (!data) { if (!data) {
pr_err("Failed to allocate LZO data\n"); pr_err("Failed to allocate LZO data\n");
ret = -ENOMEM; ret = -ENOMEM;
goto out_clean; goto out_clean;
} }
for (thr = 0; thr < nr_threads; thr++)
memset(&data[thr], 0, offsetof(struct dec_data, go));
crc = kmalloc(sizeof(*crc), GFP_KERNEL); crc = kzalloc(sizeof(*crc), GFP_KERNEL);
if (!crc) { if (!crc) {
pr_err("Failed to allocate crc\n"); pr_err("Failed to allocate crc\n");
ret = -ENOMEM; ret = -ENOMEM;
goto out_clean; goto out_clean;
} }
memset(crc, 0, offsetof(struct crc_data, go));
clean_pages_on_decompress = true; clean_pages_on_decompress = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment