From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============0601517159666276540==" MIME-Version: 1.0 From: kernel test robot Subject: [PATCH] userfaultfd: fix bugon.cocci warnings Date: Fri, 07 May 2021 10:49:25 +0800 Message-ID: <20210507024925.GA18090@55e44ba7bf01> In-Reply-To: <202105071046.QWLmGQI1-lkp@intel.com> List-Id: To: kbuild@lists.01.org --===============0601517159666276540== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable CC: kbuild-all(a)lists.01.org TO: Andrea Arcangeli CC: Andrew Morton CC: Linux Memory Management List CC: linux-kernel(a)vger.kernel.org From: kernel test robot mm/userfaultfd.c:831:3-6: WARNING: Use BUG_ON instead of if condition follo= wed by BUG. Please make sure the condition has no side effects (see conditional BUG_ON = definition in include/asm-generic/bug.h) mm/userfaultfd.c:883:3-6: WARNING: Use BUG_ON instead of if condition follo= wed 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: 02c0714c4e4f ("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 master head: 231327dd5f394c1d032155b7819eeca9e0efe5fd commit: 02c0714c4e4f79be9c34d6a7b3614f86f2967210 [33/37] userfaultfd: UFFDI= O_REMAP uABI :::::: branch date: 4 hours ago :::::: commit date: 4 hours ago Please take the patch only if it's a positive warning. Thanks! userfaultfd.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -826,9 +826,7 @@ static int remap_pages_pte(struct mm_str WRITE_ONCE(src_page->index, linear_page_index(dst_vma, dst_addr)); = - if (!pte_same(ptep_clear_flush(src_vma, src_addr, src_pte), - orig_src_pte)) - BUG(); + BUG_ON(!pte_same(ptep_clear_flush(src_vma, src_addr, src_pte), orig_src_= pte)); = orig_dst_pte =3D mk_pte(src_page, dst_vma->vm_page_prot); orig_dst_pte =3D maybe_mkwrite(pte_mkdirty(orig_dst_pte), @@ -878,9 +876,7 @@ static int remap_pages_pte(struct mm_str return -EAGAIN; } = - if (pte_val(ptep_get_and_clear(src_mm, src_addr, src_pte)) !=3D - pte_val(orig_src_pte)) - BUG(); + BUG_ON(pte_val(ptep_get_and_clear(src_mm, src_addr, src_pte)) !=3D pte_v= al(orig_src_pte)); set_pte_at(dst_mm, dst_addr, dst_pte, orig_src_pte); = if (dst_mm !=3D src_mm) { --===============0601517159666276540==--