From: sashiko-bot@kernel.org
To: "Markus Probst" <markus.probst@posteo.de>
Cc: ojeda@kernel.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v14 1/3] rust: add basic serial device bus abstractions
Date: Wed, 15 Jul 2026 21:16:04 +0000 [thread overview]
Message-ID: <20260715211605.013001F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260715-rust_serdev-v14-1-b4ed5c93606f@posteo.de>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Drivers cannot synchronously wait for data during `probe` without causing a deadlock, because `receive_buf_callback` blocks on a mutex held by `probe_callback`.
- [High] Concurrent device callbacks during unbind or probe failure lead to Use-After-Free (UAF) or NULL pointer dereference because driver data is cleared before the device is closed.
- [High] `Device::set_baudrate` incorrectly treats approximate baudrates as errors, which will fail driver initialization on many hardware platforms.
--
--- Patch [1]: [PATCH v14 1/3] rust: add basic serial device bus abstractions ---
Note: The format of this review is altered to provide a free-form summary of
the findings, rather than inline diff comments, due to system recitation
restrictions.
commit c091dc3bf08c045ff86b0afe5e41d3fd0a94bb83
Author: Markus Probst <markus.probst@posteo.de>
Subject: rust: add basic serial device bus abstractions
Implement the basic serial device bus abstractions required to write a
serial device bus device driver.
[Severity: High]
In Adapter<T>::probe_callback(), the code acquires the active mutex and
holds it across serdev_device_open() and data.__pinned_init(). If a driver
needs to send a command to the device and synchronously wait for a response
during its probe routine, won't this cause a deadlock?
When the device responds, Adapter<T>::receive_buf_callback() is invoked in
the RX workqueue and attempts to lock the exact same active mutex. Since
probe_callback() is blocked waiting for the response, and
receive_buf_callback() is blocked waiting for the mutex, the system seems
like it will deadlock. Is it possible to unlock before waiting, or use a
different synchronization strategy?
[Severity: High]
Looking at Adapter<T>::remove_callback(), it appears that T::unbind() is
called, but PrivateData is never explicitly dropped or obtained from the
device data, which might leave the device open and leak memory.
When remove_callback() returns, the C driver core sets drvdata to NULL. If
data arrives immediately after, receive_buf_callback() might read a NULL
pointer from drvdata_borrow() and dereference it.
Similarly, on a probe error in Adapter<T>::probe_callback(), ScopeGuard
clears drvdata before PrivateData's PinnedDrop implementation closes the
device. Does this create a race window where the device is still open and
receiving data while drvdata is NULL or in the process of being destroyed?
[Severity: High]
In Device::set_baudrate(), the success condition is checked using strict
equality (ret == speed).
Since serdev_device_set_baudrate() configures the hardware and returns the
actual achieved baudrate (or 0 on failure), hardware clock divider
limitations often result in a baudrate that is close but not exactly equal
to the requested speed (for example, returning 115198 when 115200 is
requested).
Will this strict equality check cause valid driver initializations to fail
on platforms that can only approximate the requested baudrate?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260715-rust_serdev-v14-0-b4ed5c93606f@posteo.de?part=1
next prev parent reply other threads:[~2026-07-15 21:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 21:00 [PATCH v14 0/3] rust: add basic serial device bus abstractions Markus Probst
2026-07-15 21:00 ` [PATCH v14 1/3] " Markus Probst
2026-07-15 21:16 ` sashiko-bot [this message]
2026-07-15 21:00 ` [PATCH v14 2/3] samples: rust: add Rust serial device bus sample device driver Markus Probst
2026-07-15 21:18 ` sashiko-bot
2026-07-15 21:00 ` [PATCH v14 3/3] MAINTAINERS: serdev: Add self for serdev Markus Probst
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=20260715211605.013001F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=markus.probst@posteo.de \
--cc=ojeda@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.