[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a272d209e84fda3c74385bf104a5f209ae7bc6a1.camel@perches.com>
Date: Sun, 11 Oct 2020 13:14:40 -0700
From: Joe Perches <joe@...ches.com>
To: Petko Manolov <petkan@...leusys.com>
Cc: Jakub Kicinski <kuba@...nel.org>,
Anant Thazhemadam <anant.thazhemadam@...il.com>,
davem@...emloft.net, linux-usb@...r.kernel.org,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-kernel-mentees@...ts.linuxfoundation.org,
linux-next@...r.kernel.org, sfr@...b.auug.org.au
Subject: Re: [PATCH v2] net: usb: rtl8150: don't incorrectly assign random
MAC addresses
On Sun, 2020-10-11 at 22:31 +0300, Petko Manolov wrote:
> On 20-10-11 11:33:00, Joe Perches wrote:
> > On Sun, 2020-10-11 at 10:59 -0700, Jakub Kicinski wrote:
> > > On Sun, 11 Oct 2020 23:00:30 +0530 Anant Thazhemadam wrote:
> > > > In set_ethernet_addr(), if get_registers() succeeds, the ethernet address
> > > > that was read must be copied over. Otherwise, a random ethernet address
> > > > must be assigned.
> > > >
> > > > get_registers() returns 0 if successful, and negative error number
> > > > otherwise. However, in set_ethernet_addr(), this return value is
> > > > incorrectly checked.
> > > >
> > > > Since this return value will never be equal to sizeof(node_id), a
> > > > random MAC address will always be generated and assigned to the
> > > > device; even in cases when get_registers() is successful.
> > > >
> > > > Correctly modifying the condition that checks if get_registers() was
> > > > successful or not fixes this problem, and copies the ethernet address
> > > > appropriately.
> >
> > There are many unchecked uses of set_registers and get_registers
> > in this file.
> >
> > If failures are really expected, then it might be better to fix
> > them up too.
>
> Checking the return value of each get/set_registers() is going to be a PITA and
> not very helpful. Doing so when setting the MAC address _does_ make sense as in
> that case it is not a hard error.
>
> In almost all other occasions if usb_control_msg_send/recv() return an error i'd
> rather dump an error message (from within get/set_registers()) and let the user
> decide whether to get rid of this adapter or start debugging it.
Your code, your choices...
Consider using _once or _ratelimited output too.
Powered by blists - more mailing lists