From: Martin Kaiser <martin@kaiser.cx>
To: Larry Finger <Larry.Finger@lwfinger.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-staging@lists.linux.dev, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org, Martin Kaiser <martin@kaiser.cx>,
Dan Carpenter <dan.carpenter@oracle.com>
Subject: [PATCH v2] staging: rtl8188eu: fix usb_submit_urb error handling
Date: Sun, 20 Jun 2021 19:40:57 +0200 [thread overview]
Message-ID: <20210620174057.10201-1-martin@kaiser.cx> (raw)
In-Reply-To: <20210612180019.20387-1-martin@kaiser.cx>
usb_read_port prepares a bulk in urb and calls usb_submit_urb to pass the
usb to the usb core. It seems wrong that usb_read_port returns success to
its caller if usb_submit_urb failed with -EPERM.
According to drivers/usb/core/urb.c, usb_submit_urb returns -EPERM when
an urb is resubmitted after being cancelled by usb_kill_urb etc.
The only caller who checks the return value of usb_read_port is
rtw_hal_inirp_init. This function submits the bulk in urbs for the first
time after the netdevice is opened. We'll not receive -EPERM from
usb_submit_urb in this case. The urbs are resubmitted by
read_port_complete, which does not check for errors from usb_read_port.
This driver may kill pending bulk in urbs when the netdevice is closed when
the driver is unloaded or the system goes to sleep. I don't think that this
will interrupt an ongoing netdev open.
Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Martin Kaiser <martin@kaiser.cx>
---
v2:
- improved the commit message based on explanations from Greg and Dan
drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
index ec07b2017fb7..0ceb05f3884f 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
@@ -366,7 +366,6 @@ u32 usb_read_port(struct adapter *adapter, u32 addr, struct recv_buf *precvbuf)
struct usb_device *pusbd = pdvobj->pusbdev;
int err;
unsigned int pipe;
- u32 ret = _SUCCESS;
if (adapter->bDriverStopped || adapter->bSurpriseRemoved ||
adapter->pwrctrlpriv.pnp_bstop_trx) {
@@ -403,10 +402,10 @@ u32 usb_read_port(struct adapter *adapter, u32 addr, struct recv_buf *precvbuf)
precvbuf);/* context is precvbuf */
err = usb_submit_urb(purb, GFP_ATOMIC);
- if ((err) && (err != (-EPERM)))
- ret = _FAIL;
+ if (err)
+ return _FAIL;
- return ret;
+ return _SUCCESS;
}
void rtw_hal_inirp_deinit(struct adapter *padapter)
--
2.20.1
prev parent reply other threads:[~2021-06-20 17:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-12 18:00 [PATCH 1/6] staging: rtl8188eu: remove unused hal_data_8188e members Martin Kaiser
2021-06-12 18:00 ` [PATCH 2/6] staging: rtl8188eu: fix usb_submit_urb error handling Martin Kaiser
2021-06-14 14:46 ` Greg Kroah-Hartman
2021-06-15 6:47 ` Dan Carpenter
2021-06-12 18:00 ` [PATCH 3/6] staging: rtl8188eu: remove a write-only struct member Martin Kaiser
2021-06-12 18:00 ` [PATCH 4/6] staging: rtl8188eu: remove a write-only power-index members Martin Kaiser
2021-06-12 18:00 ` [PATCH 5/6] staging: rtl8188eu: remove another write-only member Martin Kaiser
2021-06-12 18:00 ` [PATCH 6/6] staging: rtl8188eu: remove RT_TRACE and DBG_88E prints from usb_intf.c Martin Kaiser
2021-06-14 11:34 ` Dan Carpenter
2021-06-14 14:58 ` Martin Kaiser
2021-06-20 17:40 ` Martin Kaiser [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=20210620174057.10201-1-martin@kaiser.cx \
--to=martin@kaiser.cx \
--cc=Larry.Finger@lwfinger.net \
--cc=dan.carpenter@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
/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;
as well as URLs for NNTP newsgroup(s).