lkml.org 
[lkml]   [2018]   [Oct]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/2 -mm] mm: brk: fix unsigned compare against 0 issue
Date
Static analysis reported unsigned compare against 0 issue according to
Colin Ian King.

Defined an int temp variable to check the return value of __do_munmap().

Reported-by: Colin Ian King <colin.king@canonical.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Laurent Dufour <ldufour@linux.vnet.ibm.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Yang Shi <yang.shi@linux.alibaba.com>
---
Andrew, this should be able to be folded into the original patch.

mm/mmap.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index 68dc4fb..c78f7e9 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -242,17 +242,18 @@ static int do_brk_flags(unsigned long addr, unsigned long request, unsigned long
* __do_munmap() may downgrade mmap_sem to read.
*/
if (brk <= mm->brk) {
+ int ret;
/*
* mm->brk need to be protected by write mmap_sem, update it
* before downgrading mmap_sem.
* When __do_munmap fail, it will be restored from origbrk.
*/
mm->brk = brk;
- retval = __do_munmap(mm, newbrk, oldbrk-newbrk, &uf, true);
- if (retval < 0) {
+ ret = __do_munmap(mm, newbrk, oldbrk-newbrk, &uf, true);
+ if (ret < 0) {
mm->brk = origbrk;
goto out;
- } else if (retval == 1)
+ } else if (ret == 1)
downgraded = true;
goto success;
}
--
1.8.3.1
\
 
 \ /
  Last update: 2018-10-04 23:15    [W:0.036 / U:0.324 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site