From: sashiko-bot@kernel.org
To: "Gaosheng Cui" <cuigaosheng1@huawei.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH -next,v4] serial: core: fix NULL/dangling port_dev on failed re-register
Date: Tue, 29 Sep 2026 02:45:44 +0000 [thread overview]
Message-ID: <20260929024545.3009A1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260929023155.3259567-1-cuigaosheng1@huawei.com>
> From: Cui GaoSheng <cuigaosheng1@huawei.com>
>
> serial8250_unregister_port() removes a port and then re-registers it
> against the legacy serial8250 device when that device is still
> present, ignoring the return value of uart_add_one_port(). When the
> re-register fails, the error path of serial_core_register_port()
> removes the port device but leaves port->port_dev dangling (or NULL
> if the port device allocation itself failed). serial8250 matches
> ports on ->dev, so such half-registered slots still reach
> serial_core_unregister_port() on the next unbind:
>
> KASAN: null-ptr-deref in range [0x40-0x47]
> RIP: serial_core_unregister_port+0xe5/0xa00
> serial8250_unregister_port+0x103
> serial8250_remove+0x61
>
> Fix the error path to clear port->port_dev, and bail out of
> serial_core_unregister_port() when port_dev is NULL. Read
> port->port_dev under port_mutex, like all of its writers.
>
> Fixes: 84a9582fd203 ("serial: core: Start managing serial controllers to enable runtime PM")
> Assisted-by: LLM
> Signed-off-by: Cui GaoSheng <cuigaosheng1@huawei.com>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260929023155.3259567-1-cuigaosheng1@huawei.com?part=1
prev parent reply other threads:[~2026-09-29 2:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-29 2:31 [PATCH -next,v4] serial: core: fix NULL/dangling port_dev on failed re-register Gaosheng Cui
2026-09-29 2:45 ` sashiko-bot [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=20260929024545.3009A1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=cuigaosheng1@huawei.com \
--cc=linux-serial@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox