lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 6 Jun 2023 05:19:26 -0700
From:   Linus Torvalds <torvalds@...ux-foundation.org>
To:     Jiri Kosina <jikos@...nel.org>
Cc:     Benjamin Tissoires <benjamin.tissoires@...hat.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [GIT PULL] HID regression fix

On Mon, Jun 5, 2023 at 2:39 PM Jiri Kosina <jikos@...nel.org> wrote:
>
> - Final, confirmed fix for regression causing some devices connected via
>   Logitech HID++ Unifying receiver take too long to initialize (Benjamin
>   Tissoires)

Thanks.

The 'don't use goto' looks good, but can we simplify things further?

In particular, this kind of loop is why "do { } while ()" exists.

But also, testing "ret" in that end condition is all kinds of strange.
It smells of Pascal loops, because Pascal didn't have any sane control
flow (little known fact: in a rare show of self-reflection, "Pascal"
was named to sound like the Finnish word "paska", meaning "shit").

The *sane* thing to do is not to test "ret" in the loop condition, but
just add the obvious control flow - so the code that wants to retry
should just do 'continue' in that loop.

Then the loop itself ends up being just

        do {
                ...
        } while (--max_retries);

and we don't need any fake initialization of 'ret'.

Anyway, just a thought.

It would also simplify things a lot if that function was split up so
that you'd have that whole loop in a helper function. That way it
could just use "return ret" or whatever, with the mutex_lock/unlock in
the caller.

Btw, it does look like the code is mixing two different kinds of
return types in 'ret': regular Linux error numbers as negative
numbers, but then possibly positive "HIDPP status" values that it gets
from the report (ie

        ret = response->rap.params[1];

ends up being returned as a value, mixed with

        ret = -ETIMEDOUT;

so which is it? A negative error, or a positive HID report byte value? Or both?

             Linus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ