All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "YuanZhe Liu" <25031212351@stu.xidian.edu.cn>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH v3 2/3] USB: serial: kobil_sct: serialize concurrent writes
Date: Mon, 30 Nov 2026 12:25:58 +0000	[thread overview]
Message-ID: <sashiko-outbox-241047@kernel.org> (raw)
In-Reply-To: <20261130120548.8509-3-25031212351@stu.xidian.edu.cn>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] USB: serial: kobil_sct: uninitialized priv->sending in
  kobil_port_probe()
--

commit 2fcc2a6c5514be5945d43741a898bd74daec0c68
Author: YuanZhe Liu <25031212351@stu.xidian.edu.cn>

USB: serial: kobil_sct: serialize concurrent writes

This commit adds a spinlock and a sending flag to struct kobil_private to
serialize access to the transmit buffer in kobil_write() and
kobil_write_room().

> diff --git a/drivers/usb/serial/kobil_sct.c b/drivers/usb/serial/kobil_sct.c
> index f1c3b53c264f2..aa4170ba36763 100644
> --- a/drivers/usb/serial/kobil_sct.c
> +++ b/drivers/usb/serial/kobil_sct.c
> @@ -106,6 +106,8 @@ struct kobil_private {
>  	int cur_pos; /* index of the next char to send in buf */
>  	__u16 device_type;
>  	struct completion write_done;
> +	spinlock_t lock;	/* protects the transmit buffer state */
> +	bool sending;
>  };
>  
>  static int kobil_ctrl_send(struct usb_serial_port *port, u8 req, u16 val)
> @@ -137,6 +139,7 @@ static int kobil_port_probe(struct usb_serial_port *port)
>  	priv->cur_pos = 0;
>  	priv->device_type = le16_to_cpu(serial->dev->descriptor.idProduct);
>  	init_completion(&priv->write_done);
> +	spin_lock_init(&priv->lock);

[Severity: High]
Is priv->sending left uninitialized here?

kobil_port_probe() allocates priv with kmalloc_obj(), which does not zero
memory.  If the uninitialized byte backing priv->sending is non-zero,
kobil_write() and kobil_write_room() always see priv->sending as true and
return 0 without ever reaching the path that clears it, wedging all
transmissions on the port.

A later patch in this series, commit "USB: serial: kobil_sct: move block
transmission to a work queue", initializes priv->sending in kobil_open(),
though kobil_port_probe() still leaves it uninitialized after
kmalloc_obj().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130120548.8509-1-25031212351@stu.xidian.edu.cn?part=2

  reply	other threads:[~2026-11-30 12:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 12:05 [PATCH v3 0/3] USB: serial: kobil_sct: fix write path races YuanZhe Liu
2026-11-30 12:05 ` [PATCH v3 1/3] USB: serial: kobil_sct: fix URB submitted while active YuanZhe Liu
2026-11-30 12:05 ` [PATCH v3 2/3] USB: serial: kobil_sct: serialize concurrent writes YuanZhe Liu
2026-11-30 12:25   ` sashiko-bot [this message]
2026-11-30 12:05 ` [PATCH v3 3/3] USB: serial: kobil_sct: move block transmission to a work queue YuanZhe Liu
2026-11-30 12:17 ` [PATCH v3 0/3] USB: serial: kobil_sct: fix write path races Johan Hovold
2026-11-30 12:29   ` YuanZhe Liu
2026-11-30 12:27 ` sashiko-bot

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=sashiko-outbox-241047@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=25031212351@stu.xidian.edu.cn \
    --cc=linux-usb@vger.kernel.org \
    --cc=sashiko-reviews@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.