From: sashiko-bot@kernel.org
To: "Tapio Reijonen" <tapio.reijonen@vaisala.com>
Cc: linux-serial@vger.kernel.org
Subject: Re: [PATCH 2/3] serial: max310x: unwind only the registered ports when probe fails
Date: Fri, 20 Nov 2026 07:39:54 +0000 [thread overview]
Message-ID: <sashiko-outbox-224640@kernel.org> (raw)
In-Reply-To: <20261120-max310x-teardown-fixes-v1-2-eb52c8b612df@vaisala.com>
> uart_add_one_port() queues work on the port it registers: set_mctrl()
> schedules md_work or, with RS485 enabled at boot, the RS485
> configuration it applies schedules rs_work instead. When the IRQ
> request or the registration of a later port then fails, the error path
> unregisters the ports but leaves that work queued, and it runs after
> probe has returned and the port memory has been freed.
>
> The same loop walks every port, and a port the register loop never
> reached still has line 0 from the allocation. If another chip holds
> line 0, the loop clears that chip's bit in max310x_lines.
> uart_remove_one_port() returns early for a port that was never
> registered, so nothing is unregistered, but line 0 is now marked free
> while the other chip still uses it: the next probe is given line 0 and
> fails in uart_add_one_port() with -EINVAL, and when the other chip is
> removed its port 0 is skipped and stays registered on freed memory.
> Reachable with two chips when the second one defers on a GPIO, for
> example.
>
> Unwind from the failure index down, with the removal helpers, so that
> only the ports that were registered are unregistered and have their
> work items cancelled, and take the exits that come before any
> registration straight to the clock release.
>
> Fixes: 78adccac1ff9 ("serial: max310x: Assign port line automatically")
> Fixes: 5d888f1c32e2 ("serial: max310x: simplify probe() and remove() error handling")
> Cc: stable@vger.kernel.org
> Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261120-max310x-teardown-fixes-v1-0-eb52c8b612df@vaisala.com?part=2
next prev parent reply other threads:[~2026-11-20 7:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 7:33 [PATCH 0/3] serial: max310x: teardown ordering and CTS locking fixes Tapio Reijonen
2026-11-20 7:33 ` [PATCH 1/3] serial: max310x: fix use-after-free on remove Tapio Reijonen
2026-11-20 7:45 ` sashiko-bot
2026-11-20 7:33 ` [PATCH 2/3] serial: max310x: unwind only the registered ports when probe fails Tapio Reijonen
2026-11-20 7:39 ` sashiko-bot [this message]
2026-11-20 7:33 ` [PATCH 3/3] serial: max310x: hold the port lock around the CTS change Tapio Reijonen
2026-11-20 7:41 ` 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-224640@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tapio.reijonen@vaisala.com \
/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).