uprobes: Do not use -EEXIST in install_breakpoint() paths
authorOleg Nesterov <oleg@redhat.com>
Wed, 8 Aug 2012 15:35:08 +0000 (17:35 +0200)
committerOleg Nesterov <oleg@redhat.com>
Tue, 28 Aug 2012 16:21:18 +0000 (18:21 +0200)
-EEXIST from install_breakpoint() no longer makes sense, all
callers should simply treat it as "success". Change the code
to return zero and simplify register_for_each_vma().

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
kernel/events/uprobes.c

index 298fbbdf57e6f7571b9702d2e6fb14d8e612c82e..3e2996b809be725a4b1e1b8e085555b67fcff2c5 100644 (file)
@@ -332,7 +332,7 @@ int __weak set_swbp(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned
         */
        result = is_swbp_at_addr(mm, vaddr);
        if (result == 1)
-               return -EEXIST;
+               return 0;
 
        if (result)
                return result;
@@ -657,7 +657,7 @@ install_breakpoint(struct uprobe *uprobe, struct mm_struct *mm,
         * Hence behave as if probe already existed.
         */
        if (!uprobe->consumers)
-               return -EEXIST;
+               return 0;
 
        if (!(uprobe->flags & UPROBE_COPY_INSN)) {
                ret = copy_insn(uprobe, vma->vm_file);
@@ -817,17 +817,11 @@ static int register_for_each_vma(struct uprobe *uprobe, bool is_register)
                    vaddr_to_offset(vma, info->vaddr) != uprobe->offset)
                        goto unlock;
 
-               if (is_register) {
+               if (is_register)
                        err = install_breakpoint(uprobe, mm, vma, info->vaddr);
-                       /*
-                        * We can race against uprobe_mmap(), see the
-                        * comment near uprobe_hash().
-                        */
-                       if (err == -EEXIST)
-                               err = 0;
-               } else {
+               else
                        remove_breakpoint(uprobe, mm, info->vaddr);
-               }
+
  unlock:
                up_write(&mm->mmap_sem);
  free: