From: Michal Pecio <michal.pecio@gmail.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: Petko Manolov <petkan@nucleusys.com>,
Simon Horman <horms@kernel.org>,
Morduan Zang <zhangdandan@uniontech.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-usb@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
syzbot+9db6c624635564ad813c@syzkaller.appspotmail.com
Subject: Re: [PATCH] usb: rtl8150: avoid using uninitialized CSCR value
Date: Wed, 8 Apr 2026 10:33:43 +0200 [thread overview]
Message-ID: <20260408103343.19cf599a.michal.pecio@gmail.com> (raw)
In-Reply-To: <76d6b341-27d5-44aa-92fb-3b8966d609df@lunn.ch>
On Mon, 6 Apr 2026 01:38:06 +0200, Andrew Lunn wrote:
> > > - get_registers(dev, CSCR, 2, &tmp);
> > > + if (get_registers(dev, CSCR, 2, &tmp) < 0)
> > > + tmp = 0;
> > > if (tmp & CSCR_LINK_STATUS)
> > > netif_carrier_on(netdev);
> > > else
> >
> > I was wondering if calling netif_carrier_off() is the right thing
> > to do in case get_registers() fail.
> >
> > There are multiple get_registers() calls that don't check the error
> > and if we do this in set_carrier() maybe we should do the same
> > thing across the whole driver?
>
> What does it actually mean if get_registers() fails? The device is
> gone? Hot unplugged? If so, you are going to get a cascade of errors,
> and then hopefully the USB core code removes the device?
>
> Are there any legitimate reasons for get_registers() to fail if the
> device is still plugged in?
In principle it might be temporary EMI or a flaky cable. These errors
rarely reach drivers due to retries in USB layer, but in extreme cases
the device may be in unknown state and it may become functional later.
IIRC net layer has some operations which are presumed trivial enough
that they would never fail, so this could be annoying.
It does seem rare enough in practice that for 25 years nobody noticed
carrier status being set to a random vaule by this driver.
BTW, some functions like rtl8150_reset() pre-set data to a value which
will be safe in case of get_register() failure. But here, unhandled
set_register() error is dodgy - the 0x10 bit may never turn on.
Regards,
Michal
next prev parent reply other threads:[~2026-04-08 8:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-02 7:07 [PATCH] usb: rtl8150: avoid using uninitialized CSCR value Morduan Zang
2026-04-02 15:51 ` Petko Manolov
2026-04-03 15:45 ` Simon Horman
2026-04-05 8:52 ` Petko Manolov
2026-04-05 23:38 ` Andrew Lunn
2026-04-08 8:33 ` Michal Pecio [this message]
2026-04-08 12:26 ` Andrew Lunn
2026-04-08 8:18 ` Morduan Zang
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=20260408103343.19cf599a.michal.pecio@gmail.com \
--to=michal.pecio@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=petkan@nucleusys.com \
--cc=syzbot+9db6c624635564ad813c@syzkaller.appspotmail.com \
--cc=zhangdandan@uniontech.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