Skip to content

Commit

Permalink
PM / hibernate: cast PAGE_SIZE to int when comparing with error code
Browse files Browse the repository at this point in the history
If PAGE_SIZE is unsigned type then negative error code will be
larger than PAGE_SIZE.

Signed-off-by: Chengguang Xu <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
Chengguang Xu authored and rafaeljw committed Jul 2, 2018
1 parent 021c917 commit d5641c6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/power/swap.c
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,7 @@ int swsusp_write(unsigned int flags)
}
memset(&snapshot, 0, sizeof(struct snapshot_handle));
error = snapshot_read_next(&snapshot);
if (error < PAGE_SIZE) {
if (error < (int)PAGE_SIZE) {
if (error >= 0)
error = -EFAULT;

Expand Down Expand Up @@ -1483,7 +1483,7 @@ int swsusp_read(unsigned int *flags_p)

memset(&snapshot, 0, sizeof(struct snapshot_handle));
error = snapshot_write_next(&snapshot);
if (error < PAGE_SIZE)
if (error < (int)PAGE_SIZE)
return error < 0 ? error : -EFAULT;
header = (struct swsusp_info *)data_of(snapshot);
error = get_swap_reader(&handle, flags_p);
Expand Down

0 comments on commit d5641c6

Please sign in to comment.