Skip to content

Commit d08970d

Browse files
bgaffrafaeljw
authored andcommitted
PM: hibernate: Clean up sync_read handling in snapshot_write_next()
In snapshot_write_next(), sync_read is set and unset in three different spots unnecessiarly. As a result there is a subtle bug where the first page after the meta data has been loaded unconditionally sets sync_read to 0. If this first PFN was actually a highmem page, then the returned buffer will be the global "buffer," and the page needs to be loaded synchronously. That is, I'm not sure we can always assume the following to be safe: handle->buffer = get_buffer(&orig_bm, &ca); handle->sync_read = 0; Because get_buffer() can call get_highmem_page_buffer() which can return 'buffer'. The easiest way to address this is just set sync_read before snapshot_write_next() returns if handle->buffer == buffer. Signed-off-by: Brian Geffon <[email protected]> Fixes: 8357376 ("[PATCH] swsusp: Improve handling of highmem") Cc: All applicable <[email protected]> [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 8d74f1d commit d08970d

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

kernel/power/snapshot.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2785,8 +2785,6 @@ int snapshot_write_next(struct snapshot_handle *handle)
27852785
if (handle->cur > 1 && handle->cur > nr_meta_pages + nr_copy_pages + nr_zero_pages)
27862786
return 0;
27872787

2788-
handle->sync_read = 1;
2789-
27902788
if (!handle->cur) {
27912789
if (!buffer)
27922790
/* This makes the buffer be freed by swsusp_free() */
@@ -2829,7 +2827,6 @@ int snapshot_write_next(struct snapshot_handle *handle)
28292827
memory_bm_position_reset(&zero_bm);
28302828
restore_pblist = NULL;
28312829
handle->buffer = get_buffer(&orig_bm, &ca);
2832-
handle->sync_read = 0;
28332830
if (IS_ERR(handle->buffer))
28342831
return PTR_ERR(handle->buffer);
28352832
}
@@ -2839,9 +2836,8 @@ int snapshot_write_next(struct snapshot_handle *handle)
28392836
handle->buffer = get_buffer(&orig_bm, &ca);
28402837
if (IS_ERR(handle->buffer))
28412838
return PTR_ERR(handle->buffer);
2842-
if (handle->buffer != buffer)
2843-
handle->sync_read = 0;
28442839
}
2840+
handle->sync_read = (handle->buffer == buffer);
28452841
handle->cur++;
28462842

28472843
/* Zero pages were not included in the image, memset it and move on. */

0 commit comments

Comments
 (0)