From: Chaosheng Qu <chaosheng.qu.linux@gmail.com>
To: linux-can@vger.kernel.org
Cc: Marc Kleine-Budde <mkl@pengutronix.de>,
Vincent Mailhol <mailhol@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 0/2] can: publish tty->disc_data only after register_candev()
Date: Wed, 11 Nov 2026 14:40:00 +0800 [thread overview]
Message-ID: <1794300000.12345.987654321@gmail.com> (raw)
In-Reply-To: <c9e14a02-c360-414f-9808-8801ba18544d@enpas.org>
Hi Max,
Thank you for the thorough review, and for taking the time to work out why the
patch felt wrong. You are right, and I am dropping this approach.
The point I missed is the first one you made: "ldisc first, then netdev" is an
implicit contract in these two drivers, and my patch interleaves it. Even if
nothing races today, the next person to touch these functions would have to
reason about SMT safety that was previously not theirs to reason about. That is
swapping one trap for another, which is exactly what I claimed to be removing.
So v3 will use your alternative instead of mine, and nothing else:
err = register_candev(dev);
if (err) {
+ tty->disc_data = NULL;
free_candev(dev);
pr_err("can't register candev\n");
return err;
}
Same in can327. The ordering stays as it is, so the implicit contract is
untouched, and the failure path no longer leaves tty->disc_data pointing at
memory that free_candev() has just released. The commit message will say that
plainly, and will state why no barrier or extra locking is needed: the pointer
is read exactly where it was read before, and the only write on this path
happens before the interface can be brought up.
The sashiko report on 1/2 (a lost tty_wakeup while ldisc_sem is held) also goes
away with your version, since nothing is reordered any more.
On your question: yes. I use an AI assistant when I write patches, and the
disclosure line required by Documentation/process/coding-assistants.rst will be
on v3. Your instinct about why this one looked too neat is right: the assistant
was good at exactly one thing here, finding the smallest diff that removes the
dangling pointer, and moving the assignment is a smaller diff than clearing it.
That is the move that quietly crossed the SMT boundary. Knowing when the
smaller diff is the wrong one is still my job, and I got it wrong.
v3 in a day or two, after I have re-read both drivers end to end rather than
trusting the diff.
Thanks,
Chaosheng
prev parent reply other threads:[~2026-11-11 6:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 6:11 Chaosheng Qu
2026-10-16 6:11 ` [PATCH net-next 1/2] can: slcan: " Chaosheng Qu
2026-10-16 6:11 ` [PATCH net-next 2/2] can: can327: " Chaosheng Qu
2026-10-16 14:10 ` Max
[not found] ` <179289472575.8393.17187271051946169028@gmail.com>
[not found] ` <c9e14a02-c360-414f-9808-8801ba18544d@enpas.org>
2026-11-11 6:40 ` Chaosheng Qu [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=1794300000.12345.987654321@gmail.com \
--to=chaosheng.qu.linux@gmail.com \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
/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
all inboxes | Powered by JetHome®