From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============1242087800614721148==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] userfaultfd: fix bugon.cocci warnings Date: Thu, 23 Dec 2021 10:47:15 +0800 Message-ID: <20211223024714.GA11963@6c97301a9aff> List-Id: To: kbuild@lists.01.org --===============1242087800614721148== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CC: kbuild-all(a)lists.01.org CC: linux-kernel(a)vger.kernel.org TO: Andrea Arcangeli CC: Andrew Morton CC: Linux Memory Management List CC: linux-kernel(a)vger.kernel.org From: kernel test robot mm/huge_memory.c:1987:2-5: WARNING: Use BUG_ON instead of if condition foll= owed by BUG. Please make sure the condition has no side effects (see conditional BUG_ON = definition in include/asm-generic/bug.h) Use BUG_ON instead of a if condition followed by BUG. Semantic patch information: This makes an effort to find cases where BUG() follows an if condition on an expression and replaces the if condition and BUG() with a BUG_ON having the conditional expression of the if statement as argument. Generated by: scripts/coccinelle/misc/bugon.cocci Fixes: f656fca095ea ("userfaultfd: UFFDIO_REMAP uABI") Reported-by: kernel test robot Signed-off-by: kernel test robot --- tree: https://git.kernel.org/pub/scm/linux/kernel/git/andrea/aa.git main head: e37fc15fcde08ff18027c1a1e34b2371ac2c449b commit: f656fca095eaa2bc257fee306e02c92f229031c9 [38/50] userfaultfd: UFFDI= O_REMAP uABI :::::: branch date: 23 hours ago :::::: commit date: 23 hours ago Please take the patch only if it's a positive warning. Thanks! huge_memory.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1982,9 +1982,7 @@ int remap_pages_huge_pmd(struct mm_struc WRITE_ONCE(src_page->mapping, (struct address_space *) dst_anon_vma); WRITE_ONCE(src_page->index, linear_page_index(dst_vma, dst_addr)); = - if (!pmd_same(pmdp_huge_clear_flush(src_vma, src_addr, src_pmd), - src_pmdval)) - BUG(); + BUG_ON(!pmd_same(pmdp_huge_clear_flush(src_vma, src_addr, src_pmd), src_p= mdval)); _dst_pmd =3D mk_huge_pmd(src_page, dst_vma->vm_page_prot); _dst_pmd =3D maybe_pmd_mkwrite(pmd_mkdirty(_dst_pmd), dst_vma); set_pmd_at(dst_mm, dst_addr, dst_pmd, _dst_pmd); --===============1242087800614721148==--