mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: Robert Hodaszi <robert.hodaszi@digi.com>,
	gregkh@linuxfoundation.org, oneukum@suse.com
Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
	stern@rowland.harvard.edu, viro@zeniv.linux.org.uk
Subject: Re: [PATCH] usb: cdc-wdm: avoid setting WDM_READ for ZLP-s
Date: Mon, 7 Apr 2025 11:23:03 +0200	[thread overview]
Message-ID: <9fdb5e30-8570-420f-940b-bea5fa72e12d@suse.com> (raw)
In-Reply-To: <20250403144004.3889125-1-robert.hodaszi@digi.com>



On 03.04.25 16:40, Robert Hodaszi wrote:
> Don't set WDM_READ flag in wdm_in_callback() for ZLP-s, otherwise when
> userspace tries to poll for available data, it might - incorrectly -
> believe there is something available, and when it tries to non-blocking
> read it, it might get stuck in the read loop.
> 
> For example this is what glib does for non-blocking read (briefly):
> 
>    1. poll
>    2. if poll returns with non-zero, starts a read data loop:
>      a. loop on poll() (EINTR disabled)
>      b. if revents was set, reads data
>        I. if read returns with EINTR or EAGAIN, goto 2.a.
>        II. otherwise return with data
> 
> So if ZLP sets WDM_READ (#1), we expect data, and try to read it (#2).
> But as that was a ZLP, and we are doing non-blocking read, wdm_read()
> returns with EAGAIN (#2.b.I), so loop again, and try to read again
> (#2.a.).
> 
> With glib, we might stuck in this loop forever, as EINTR is disabled
> (#2.a).
> 
> Signed-off-by: Robert Hodaszi <robert.hodaszi@digi.com>
Acked-by: Oliver Neukum <oneukum@suse.com>


      reply	other threads:[~2025-04-07  9:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-03 14:40 Robert Hodaszi
2025-04-07  9:23 ` Oliver Neukum [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9fdb5e30-8570-420f-940b-bea5fa72e12d@suse.com \
    --to=oneukum@suse.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=robert.hodaszi@digi.com \
    --cc=stern@rowland.harvard.edu \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®