On 03/22, Anton Arapov wrote:
>
> @@ -1488,10 +1496,14 @@ static void handler_chain(struct uprobe *uprobe, 
> struct pt_regs *regs)
>  {
>       struct uprobe_consumer *uc;
>       int remove = UPROBE_HANDLER_REMOVE;
> +     int rc = 0;
>  
>       down_read(&uprobe->register_rwsem);
>       for (uc = uprobe->consumers; uc; uc = uc->next) {
> -             int rc = uc->handler(uc, regs);
> +             if (uc->handler)
> +                     rc = uc->handler(uc, regs);
> +             else
> +                     remove = 0;

Well, this doesn't look good. Yes, we need to conditionalize uc->handler()
and rc checks, but the code looks ugly. We touch remove twice, and the value
of rc inside the loop is bogus if ->handler == NULL.

I wouldn't have argued, but, but 4/7 changes the "else" branch and this change
is wrong (I'll write another email). We do not need this "else" at all.

I'd suggest the patch below.

Oleg.

--- x/kernel/events/uprobes.c
+++ x/kernel/events/uprobes.c
@@ -1491,10 +1491,13 @@ static void handler_chain(struct uprobe 
 
        down_read(&uprobe->register_rwsem);
        for (uc = uprobe->consumers; uc; uc = uc->next) {
-               int rc = uc->handler(uc, regs);
+               int rc = 0;
 
-               WARN(rc & ~UPROBE_HANDLER_MASK,
-                       "bad rc=0x%x from %pf()\n", rc, uc->handler);
+               if (uc->handler) {
+                       rc = uc->handler(uc, regs);
+                       WARN(rc & ~UPROBE_HANDLER_MASK,
+                               "bad rc=0x%x from %pf()\n", rc, uc->handler);
+               }
                remove &= rc;
        }
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to