linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kernel/power: cast PAGE_SIZE to int when comparing with error code
@ 2018-06-25  5:30 Chengguang Xu
  2018-07-02  1:10 ` cgxu519
  0 siblings, 1 reply; 4+ messages in thread
From: Chengguang Xu @ 2018-06-25  5:30 UTC (permalink / raw)
  To: rjw, pavel, len.brown; +Cc: linux-pm, linux-kernel, Chengguang Xu

If PAGE_SIZE is unsigned type then negative error code will be
larger than PAGE_SIZE.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
 kernel/power/swap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index c2bcf97d24c8..d7f6c1a288d3 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -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;
 
@@ -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);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] kernel/power: cast PAGE_SIZE to int when comparing with error code
  2018-06-25  5:30 [PATCH] kernel/power: cast PAGE_SIZE to int when comparing with error code Chengguang Xu
@ 2018-07-02  1:10 ` cgxu519
  2018-07-02  7:14   ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: cgxu519 @ 2018-07-02  1:10 UTC (permalink / raw)
  To: rjw; +Cc: pavel, cgxu519, linux-pm, linux-kernel

Hi Rafael,

Could you have a look at this simple patch?

Thanks,
Chengguang


On 06/25/2018 01:30 PM, Chengguang Xu wrote:
> If PAGE_SIZE is unsigned type then negative error code will be
> larger than PAGE_SIZE.
>
> Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
> ---
>   kernel/power/swap.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/power/swap.c b/kernel/power/swap.c
> index c2bcf97d24c8..d7f6c1a288d3 100644
> --- a/kernel/power/swap.c
> +++ b/kernel/power/swap.c
> @@ -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;
>   
> @@ -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);


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kernel/power: cast PAGE_SIZE to int when comparing with error code
  2018-07-02  1:10 ` cgxu519
@ 2018-07-02  7:14   ` Rafael J. Wysocki
  2018-07-04 10:50     ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2018-07-02  7:14 UTC (permalink / raw)
  To: cgxu519
  Cc: Rafael J. Wysocki, Pavel Machek, Linux PM, Linux Kernel Mailing List

On Mon, Jul 2, 2018 at 3:10 AM, cgxu519 <cgxu519@gmx.com> wrote:
> Hi Rafael,
>
> Could you have a look at this simple patch?

I've done that already and I'm going to apply it.

Thanks,
Rafael


> On 06/25/2018 01:30 PM, Chengguang Xu wrote:
>>
>> If PAGE_SIZE is unsigned type then negative error code will be
>> larger than PAGE_SIZE.
>>
>> Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
>> ---
>>   kernel/power/swap.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/kernel/power/swap.c b/kernel/power/swap.c
>> index c2bcf97d24c8..d7f6c1a288d3 100644
>> --- a/kernel/power/swap.c
>> +++ b/kernel/power/swap.c
>> @@ -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;
>>   @@ -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);
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kernel/power: cast PAGE_SIZE to int when comparing with error code
  2018-07-02  7:14   ` Rafael J. Wysocki
@ 2018-07-04 10:50     ` Rafael J. Wysocki
  0 siblings, 0 replies; 4+ messages in thread
From: Rafael J. Wysocki @ 2018-07-04 10:50 UTC (permalink / raw)
  To: cgxu519; +Cc: Pavel Machek, Linux PM, Linux Kernel Mailing List

On Monday, July 2, 2018 9:14:03 AM CEST Rafael J. Wysocki wrote:
> On Mon, Jul 2, 2018 at 3:10 AM, cgxu519 <cgxu519@gmx.com> wrote:
> > Hi Rafael,
> >
> > Could you have a look at this simple patch?
> 
> I've done that already and I'm going to apply it.

Applied now, thanks!


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-07-04 10:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-25  5:30 [PATCH] kernel/power: cast PAGE_SIZE to int when comparing with error code Chengguang Xu
2018-07-02  1:10 ` cgxu519
2018-07-02  7:14   ` Rafael J. Wysocki
2018-07-04 10:50     ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).