[PATCH] mm/zswap: fix variable 'entry' is uninitialized when used

the entry has not been initialized when it is used, so allocate PAGE_SIZE Signed-off-by: Tian Tao <tiantao6@hisilicon.com> Reported-by: kernel test robot <lkp@intel.com> --- mm/zswap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/zswap.c b/mm/zswap.c index 6e0bb61..4b7b6ad 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -944,7 +944,7 @@ static int zswap_writeback_entry(struct zpool *pool, unsigned long handle) if (!zpool_can_sleep_mapped(pool)) { - tmp = kmalloc(entry->length, GFP_ATOMIC); + tmp = kmalloc(PAGE_SIZE, GFP_ATOMIC); if (!tmp) return -ENOMEM; } -- 2.7.4

-----Original Message----- From: tiantao (H) Sent: Thursday, January 21, 2021 10:39 PM To: Song Bao Hua (Barry Song) <song.bao.hua@hisilicon.com> Cc: linuxarm@openeuler.org; tiantao (H) <tiantao6@hisilicon.com> Subject: [PATCH] mm/zswap: fix variable 'entry' is uninitialized when used
the entry has not been initialized when it is used, so allocate PAGE_SIZE
Signed-off-by: Tian Tao <tiantao6@hisilicon.com> Reported-by: kernel test robot <lkp@intel.com>
Guess Andrew hasn't sent pull request to Linus yet? So just send v2 for the merged patch with this fix, Andrew will put the new patch in mm tree.
--- mm/zswap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/zswap.c b/mm/zswap.c index 6e0bb61..4b7b6ad 100644 --- a/mm/zswap.c +++ b/mm/zswap.c @@ -944,7 +944,7 @@ static int zswap_writeback_entry(struct zpool *pool, unsigned long handle)
if (!zpool_can_sleep_mapped(pool)) {
- tmp = kmalloc(entry->length, GFP_ATOMIC); + tmp = kmalloc(PAGE_SIZE, GFP_ATOMIC); if (!tmp) return -ENOMEM; } -- 2.7.4 Thanks Barry
participants (2)
-
Song Bao Hua (Barry Song)
-
Tian Tao