Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3312833imm; Sun, 1 Jul 2018 18:17:56 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfJvLWg6jwKG7+xVLVQrL+whRDo3EOGAblowINblkJVy5WnkDLVLB1FlninYI4ygcDLZknH X-Received: by 2002:a62:864a:: with SMTP id x71-v6mr3655430pfd.252.1530494276481; Sun, 01 Jul 2018 18:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530494276; cv=none; d=google.com; s=arc-20160816; b=PPwIG3MxR4En7uvyOdAzOFc50q6f9bFYfwS/PieHUFlzKCOrUtPKVvHv4PnqBohAmb 0xXXAYJcPL7VquY46cConJUGGsGeiQa8mvNuWdzGX5aMDjGfhoal8ZpDHuVsjdB0n+W9 5BiFQ/POGvyWkc/CBOeB4qm/EX4RF8mmHsKXO5MFt0MUMorIUy3kv/XOxBKOtbUeIRL+ pa40lkxM8sXiwYT4ops6OMo5UdhJc4rxGtCbDkts+rdPP5JgJ3X6EWivc4Uj9SO7XAx5 lwIibSk+6LsDwkpzCyfIe9gzqklo65a65AN6YNBjLRl56qJ942rP91NIJQsWZ48atGYc qRiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=0bLA4bV38/nXBmkHQ35D3bcSdSWiO7j506cSMn0tnP0=; b=hGg/nUf86Wb9wDcAyL9DF560Wkw5IICnE3pZ9ofUWh61P0OvXMFIGpmUuW1nKp0VGH 8d7djOdNJGJpEJPIHNuZG6axCFfiWTtk84tty1rlKDIRQ/rTUkC1xoMq9Zix5ZVKded0 +Y3BJXxkYj9ZFk9ItV67yjNtVaF4GZf28ZLs43WcGLUAaykhFvKMW7pkKNlX4lCZMdB5 F9zAMY8fHjjOOhzLKDrgQo+p1iYpQC+jfLJQ8GR4+mXM++euup3YVtsHmjUy406YgWef ziq9vsumG+GQd5Utk8+7RQbW51euZKUteGzYlr557sN5pG2uCOVb6SdWbfizTmCbMfrx Iqtw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z10-v6si10662413pgo.412.2018.07.01.18.17.41; Sun, 01 Jul 2018 18:17:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932580AbeGBBLG (ORCPT + 99 others); Sun, 1 Jul 2018 21:11:06 -0400 Received: from mout.gmx.net ([212.227.15.19]:34383 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932354AbeGBBLF (ORCPT ); Sun, 1 Jul 2018 21:11:05 -0400 Received: from [172.17.46.209] ([122.224.77.194]) by mail.gmx.com (mrgmx001 [212.227.17.184]) with ESMTPSA (Nemesis) id 0Ltqb7-1gIee13NVV-011EcQ; Mon, 02 Jul 2018 03:11:01 +0200 Subject: Re: [PATCH] kernel/power: cast PAGE_SIZE to int when comparing with error code To: rjw@rjwysocki.net Cc: pavel@ucw.cz, cgxu519@gmx.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180625053058.25206-1-cgxu519@gmx.com> From: cgxu519 Message-ID: <0a812d02-d85d-f685-6e7f-f4dfe22f9629@gmx.com> Date: Mon, 2 Jul 2018 09:10:56 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180625053058.25206-1-cgxu519@gmx.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Provags-ID: V03:K1:CvyVtmqWLvgC9lG71PAbpGIcbsnQIA6t1gByO/Gi1hzoaOzrybC qpsCmgus0ip6C/4v21k60MtIEJYverszmSW7YuxhpsNkDKPP6nPjdE2UlkC7RU+GPLsS/gB wTHjC6h1lDZz3U4LzxHlJiQ1in7+QKE0ADfc2SDJ1M0v2RiGY/7PbwlaNSK8mECdJaqE0OF kNY/X/rGbJ6S3VqBk6UwA== X-UI-Out-Filterresults: notjunk:1;V01:K0:tgB2VTSADlg=:5m2tuVAKOXM2o8cH58rV61 AmwqW4jPQUD9SBuqKTyiUiH5MYJjEUhEAecLiHWhNHao4P62k/Z1xuLFhQB1FiW4ysBDkLxwN w0hoomeJj9uXo/93yPkOrX9htLAH6cU5lqRRQa8tbJ3KDBHcWKA4CjVg1ne3DUK+s31Lf8Gbs biK5e3YN0wyfmjZEbu9UmtwVungeri/ke93VO73+XXSXp2gANZqPb3alPqCQx+1uAcGzjXYPT 2uSBBHsZH7OdHx7dd3eRQoO8Hg1THyeVifS2fKGbEEM5SVREfsb8x4yAe8lUXe3+cFRqI+A/x CnTnQ3pZGx8LBo13i6t58wPv4EHrB9OkPxRhvMPeI8gTWrZYdEqwiPyDq7z5D35BdjlydD0C1 V/WFhQROy2bXZ9Vvzs3BBY20HyJydqWX9tUBwx/S6rhWg/8OzyO3RE72y4lLP7BqnL7zme/v1 4tsVrcdrz9WdCtrY72kU4e9pWqqsI2QrukGVxLuoHwme3dRuYQBJwwfjk8pUm6fYuDECVrefZ No2WD3ALF/IIGzYlQqy9BNfPq1q+BZ/0uQxmZ8/0rhcRpeZpR6u74ezSIJhX9NvZsO6oVMFZC xiq/wlbVY8JnLIUKxR5EfNEdZURs5BBc0NvzdsdTBn8b8wh8gaPhZ29mOGvbqfzBvVFLb0GeM icLFnPuySov0Cbbdq95hAkYJ7YDCnUT88bxMrHv83v26uw8A5Uf9x/9QTtquXZmYArq9z+HKA kxrEIwA8mItNVMlANJlfPQIqRk9lqNuhWmQtGSXCVvS7zNYydybYdT9CZwzm+XSiy8CHQkb+r Jgo+IlM Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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);