From: Jakub Kicinski <kuba@kernel.org>
To: Shuangpeng <shuangpeng.kernel@gmail.com>
Cc: davem@davemloft.net, edumazet@google.com,
linux-kernel@vger.kernel.org, pabeni@redhat.com,
netdev@vger.kernel.org, horms@kernel.org,
jiayuan.chen@shopee.com, jirislaby@kernel.org,
andrew+netdev@lunn.ch, gregkh@linuxfoundation.org,
shaojijie@huawei.com
Subject: Re: [net,v4] serial: caif: hold tty->link reference in ldisc_open and ser_release
Date: Wed, 4 Mar 2026 17:39:56 -0800 [thread overview]
Message-ID: <20260304173956.0081d8ea@kernel.org> (raw)
In-Reply-To: <CC580D33-FC23-4271-ADEF-A0DEAE6BE9ED@gmail.com>
On Wed, 4 Mar 2026 20:23:20 -0500 Shuangpeng wrote:
> > Can this dereference NULL? The tty->link field is only set for PTY
> > (pseudo-terminal) pairs. For regular serial ports and other non-PTY
> > devices, tty->link is NULL.
> >
> > The CAIF line discipline can be attached to any TTY device via the
> > TIOCSETD ioctl. When ser_release() is called to clean up a ser_device
> > that was created for a non-PTY TTY device, tty->link would be NULL.
> >
> > Should this check for NULL before calling tty_kref_put()?
> >
>
> tty_kref_get() / tty_kref_put() are NULL-safe, so calling them with
> tty->link == NULL is not a functional issue.
>
> I can add explicit if (tty->link) guards to improve readability if you prefer.
Sorry, I should have checked, I'm surprised the AI agent got something
this basic wrong. Just the Fixes tag, then..
next prev parent reply other threads:[~2026-03-05 1:39 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-01 22:05 [PATCH net v4] serial: caif: hold tty->link reference in ldisc_open and ser_release Shuangpeng Bai
2026-03-04 1:26 ` [net,v4] " Jakub Kicinski
2026-03-05 1:23 ` Shuangpeng
2026-03-05 1:39 ` Jakub Kicinski [this message]
2026-03-05 16:48 ` Shuangpeng
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=20260304173956.0081d8ea@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=horms@kernel.org \
--cc=jiayuan.chen@shopee.com \
--cc=jirislaby@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shaojijie@huawei.com \
--cc=shuangpeng.kernel@gmail.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