* [PATCH] mm/zswap: Add return value in zswap_frontswap_load
@ 2021-01-21 21:48 Nathan Chancellor
2021-01-22 1:58 ` Miaohe Lin
0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2021-01-21 21:48 UTC (permalink / raw)
To: Andrew Morton
Cc: Seth Jennings, Dan Streetman, Vitaly Wool, Nick Desaulniers,
Tian Tao, linux-mm, linux-kernel, clang-built-linux,
Nathan Chancellor, kernelci . org bot, kernel test robot
Clang warns:
mm/zswap.c:1271:6: warning: variable 'ret' is used uninitialized
whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!entry->length) {
^~~~~~~~~~~~~~
mm/zswap.c:1322:9: note: uninitialized use occurs here
return ret;
^~~
mm/zswap.c:1271:2: note: remove the 'if' if its condition is always
false
if (!entry->length) {
^~~~~~~~~~~~~~~~~~~~~
mm/zswap.c:1259:9: note: initialize the variable 'ret' to silence this
warning
int ret;
^
= 0
1 warning generated.
Prior to "mm/zswap: add the flag can_sleep_mapped", this path always
returned 0. Restore that so we are not returning uninitialized memory.
Link: https://github.com/ClangBuiltLinux/linux/issues/1263
Reported-by: kernelci.org bot <bot@kernelci.org>
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
Andrew, please fold this into
mm-zswap-add-the-flag-can_sleep_mapped.patch
mm/zswap.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/zswap.c b/mm/zswap.c
index 6e0bb61d2a2c..a85334b719b9 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -1272,6 +1272,7 @@ static int zswap_frontswap_load(unsigned type, pgoff_t offset,
dst = kmap_atomic(page);
zswap_fill_page(dst, entry->value);
kunmap_atomic(dst);
+ ret = 0;
goto freeentry;
}
base-commit: bc085f8fc88fc16796c9f2364e2bfb3fef305cad
--
2.30.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/zswap: Add return value in zswap_frontswap_load
2021-01-21 21:48 [PATCH] mm/zswap: Add return value in zswap_frontswap_load Nathan Chancellor
@ 2021-01-22 1:58 ` Miaohe Lin
0 siblings, 0 replies; 2+ messages in thread
From: Miaohe Lin @ 2021-01-22 1:58 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Seth Jennings, Dan Streetman, Vitaly Wool, Nick Desaulniers,
Tian Tao, linux-mm, linux-kernel, clang-built-linux,
kernelci . org bot, kernel test robot, Andrew Morton
Hi:
On 2021/1/22 5:48, Nathan Chancellor wrote:
> Clang warns:
>
> mm/zswap.c:1271:6: warning: variable 'ret' is used uninitialized
> whenever 'if' condition is true [-Wsometimes-uninitialized]
> if (!entry->length) {
> ^~~~~~~~~~~~~~
> mm/zswap.c:1322:9: note: uninitialized use occurs here
> return ret;
> ^~~
> mm/zswap.c:1271:2: note: remove the 'if' if its condition is always
> false
> if (!entry->length) {
> ^~~~~~~~~~~~~~~~~~~~~
> mm/zswap.c:1259:9: note: initialize the variable 'ret' to silence this
> warning
> int ret;
> ^
> = 0
> 1 warning generated.
>
> Prior to "mm/zswap: add the flag can_sleep_mapped", this path always
> returned 0. Restore that so we are not returning uninitialized memory.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/1263
> Reported-by: kernelci.org bot <bot@kernelci.org>
> Reported-by: kernel test robot <lkp@intel.com>
Looks like commit 6753c561f653 ("mm/zswap: add the flag can_sleep_mapped") introduced this warning.
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>
> Andrew, please fold this into
>
> mm-zswap-add-the-flag-can_sleep_mapped.patch
>
> mm/zswap.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/mm/zswap.c b/mm/zswap.c
> index 6e0bb61d2a2c..a85334b719b9 100644
> --- a/mm/zswap.c
> +++ b/mm/zswap.c
> @@ -1272,6 +1272,7 @@ static int zswap_frontswap_load(unsigned type, pgoff_t offset,
> dst = kmap_atomic(page);
> zswap_fill_page(dst, entry->value);
> kunmap_atomic(dst);
> + ret = 0;
> goto freeentry;
> }
>
>
> base-commit: bc085f8fc88fc16796c9f2364e2bfb3fef305cad
>
Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-22 1:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-21 21:48 [PATCH] mm/zswap: Add return value in zswap_frontswap_load Nathan Chancellor
2021-01-22 1:58 ` Miaohe Lin
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).