From: Johan Hovold <johan@kernel.org>
To: Johan Hovold <johan@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 06/11] USB: serial: digi_acceleport: drop redundant driver data sanity checks
Date: Wed, 10 Jun 2026 15:22:27 +0200 [thread overview]
Message-ID: <20260610132232.356139-7-johan@kernel.org> (raw)
In-Reply-To: <20260610132232.356139-1-johan@kernel.org>
The URB context pointer does not change while an URB is in flight so
there is never a need to check for NULL on completion.
The port driver data is not freed until the port is unbound at which
point all I/O for that port has been stopped (and I/O is no longer
started for a port that has not yet been probed).
The device driver data is not freed until after the driver has been
unbound and at which point all I/O has also ceased.
Drop the redundant, overly defensive (and still incomplete) sanity
checks from the completion callbacks.
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/usb/serial/digi_acceleport.c | 40 +++-------------------------
1 file changed, 4 insertions(+), 36 deletions(-)
diff --git a/drivers/usb/serial/digi_acceleport.c b/drivers/usb/serial/digi_acceleport.c
index 7a198c4a9e28..e14cf133808f 100644
--- a/drivers/usb/serial/digi_acceleport.c
+++ b/drivers/usb/serial/digi_acceleport.c
@@ -942,28 +942,12 @@ static int digi_write(struct tty_struct *tty, struct usb_serial_port *port,
static void digi_write_bulk_callback(struct urb *urb)
{
struct usb_serial_port *port = urb->context;
- struct usb_serial *serial;
- struct digi_port *priv;
- struct digi_serial *serial_priv;
- int status = urb->status;
+ struct digi_serial *serial_priv = usb_get_serial_data(port->serial);
+ struct digi_port *priv = usb_get_serial_port_data(port);
unsigned long flags;
bool wakeup;
int ret = 0;
- /* port and serial sanity check */
- if (port == NULL || (priv = usb_get_serial_port_data(port)) == NULL) {
- pr_err("%s: port or port->private is NULL, status=%d\n",
- __func__, status);
- return;
- }
- serial = port->serial;
- if (serial == NULL || (serial_priv = usb_get_serial_data(serial)) == NULL) {
- dev_err(&port->dev,
- "%s: serial or serial->private is NULL, status=%d\n",
- __func__, status);
- return;
- }
-
/* handle oob callback */
if (priv->dp_port_num == serial_priv->ds_oob_port_num) {
dev_dbg(&port->dev, "digi_write_bulk_callback: oob callback\n");
@@ -1268,27 +1252,11 @@ static void digi_port_remove(struct usb_serial_port *port)
static void digi_read_bulk_callback(struct urb *urb)
{
struct usb_serial_port *port = urb->context;
- struct digi_port *priv;
- struct digi_serial *serial_priv;
+ struct digi_serial *serial_priv = usb_get_serial_data(port->serial);
+ struct digi_port *priv = usb_get_serial_port_data(port);
int status = urb->status;
int ret;
- /* port sanity check, do not resubmit if port is not valid */
- if (port == NULL)
- return;
- priv = usb_get_serial_port_data(port);
- if (priv == NULL) {
- dev_err(&port->dev, "%s: port->private is NULL, status=%d\n",
- __func__, status);
- return;
- }
- if (port->serial == NULL ||
- (serial_priv = usb_get_serial_data(port->serial)) == NULL) {
- dev_err(&port->dev, "%s: serial is bad or serial->private "
- "is NULL, status=%d\n", __func__, status);
- return;
- }
-
/* do not resubmit urb if it has any status error */
if (status) {
dev_err(&port->dev,
--
2.53.0
next prev parent reply other threads:[~2026-06-10 13:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-10 13:22 [PATCH 00/11] USB: serial: digi_acceleport: registration fix and cleanups Johan Hovold
2026-06-10 13:22 ` [PATCH 01/11] USB: serial: digi_acceleport: fix port registration order Johan Hovold
2026-06-10 13:22 ` [PATCH 02/11] USB: serial: digi_acceleport: drop unused wait queue Johan Hovold
2026-06-10 13:22 ` [PATCH 03/11] USB: serial: digi_acceleport: always stop write urb on close Johan Hovold
2026-06-10 13:22 ` [PATCH 04/11] USB: serial: digi_acceleport: add oob port helper Johan Hovold
2026-06-10 13:22 ` [PATCH 05/11] USB: serial: digi_acceleport: clean up declarations and whitespace Johan Hovold
2026-06-10 13:22 ` Johan Hovold [this message]
2026-06-10 13:22 ` [PATCH 07/11] USB: serial: digi_acceleport: stop OOB I/O when not in use Johan Hovold
2026-06-10 13:22 ` [PATCH 08/11] USB: serial: digi_acceleport: drop unused in-buf define Johan Hovold
2026-06-10 13:22 ` [PATCH 09/11] USB: serial: digi_acceleport: clean up xfer buf length expression Johan Hovold
2026-06-10 13:22 ` [PATCH 10/11] USB: serial: digi_acceleport: clean up write completion Johan Hovold
2026-06-10 13:22 ` [PATCH 11/11] USB: serial: digi_acceleport: clean up inb command submission Johan Hovold
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=20260610132232.356139-7-johan@kernel.org \
--to=johan@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/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