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]
Message-ID: <543c19b1ef99f9e4234750f401457cb1b83de2c6.camel@esd.eu>
Date: Wed, 24 Sep 2025 10:05:23 +0000
From: Stefan Mätje <stefan.maetje@....eu>
To: "mkl@...gutronix.de" <mkl@...gutronix.de>, "kuba@...nel.org"
	<kuba@...nel.org>
CC: "linux-can@...r.kernel.org" <linux-can@...r.kernel.org>,
	"kernel@...gutronix.de" <kernel@...gutronix.de>, "netdev@...r.kernel.org"
	<netdev@...r.kernel.org>, "davem@...emloft.net" <davem@...emloft.net>
Subject: Re: [PATCH net 08/10] can: esd_usb: Fix not detecting version reply
 in probe routine

Am Montag, dem 22.09.2025 um 17:16 -0700 schrieb Jakub Kicinski:
> On Mon, 22 Sep 2025 12:07:38 +0200 Marc Kleine-Budde wrote:
> > +	do {
> > +		int actual_length;
> > +		int pos;
> > +
> > +		err = usb_bulk_msg(dev->udev,
> > +				   usb_rcvbulkpipe(dev->udev, 1),
> > +				   rx_buf,
> > +				   ESD_USB_RX_BUFFER_SIZE,
> > +				   &actual_length,
> > +				   ESD_USB_DRAIN_TIMEOUT_MS);
> > +		dev_dbg(&dev->udev->dev, "AT %d, LEN %d, ERR %d\n", attempt, actual_length, err);
> > +		++attempt;
> > +		if (err)
> > +			goto bail;
> > +		if (actual_length == 0)
> > +			continue;
> 
> continue in do-while loops doesn't check the condition.
> This looks like a potential infinite loop?

I don't think so. A continue statement in a do, while or for loop
always jumps to the end of the loop body.

See a citation of the C standard there:
https://stackoverflow.com/a/64120354

Therefore there is no potential for an infinite loop due to the continue 
statement.

Refer to following code and its output:

----------------------------------------------
#include <stdio.h>

#define LIMIT   4

int main(void)
{
    int cnt = 0;

    do {
        printf("Top: %d\n", cnt);
        ++cnt;
        if (cnt > 2) continue;
        printf("Bottom: %d\n", cnt);
    } while (printf("Condition: %d\n\n", cnt), cnt < LIMIT);
    
	return 0;
}
----------------------------------------------

Output:
----------------------------------------------
stefanm@...stefanm64:~/Tmp$ ./do_continue 
Top: 0
Bottom: 1
Condition: 1

Top: 1
Bottom: 2
Condition: 2

Top: 2
Condition: 3

Top: 3
Condition: 4

----------------------------------------------

Sorry being late with this.

Best regards,
    Stefan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ