lkml.org 
[lkml]   [2023]   [Nov]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC PATCH net-next v2 04/10] net: sfp: Add helper to return the SFP bus name
Hi Andrew, Russell,

On Tue, 21 Nov 2023 10:20:43 +0000
"Russell King (Oracle)" <linux@armlinux.org.uk> wrote:

> On Tue, Nov 21, 2023 at 02:00:58AM +0100, Andrew Lunn wrote:
> > > +const char *sfp_get_name(struct sfp_bus *bus)
> > > +{
> > > + if (bus->sfp_dev)
> > > + return dev_name(bus->sfp_dev);
> > > +
> > > + return NULL;
> > > +}
> >
> > Locking? Do you assume rtnl? Does this function need to take rtnl?
>
> Yes, rtnl needs to be held to safely access bus->sfp_dev, and that
> either needs to happen in this function, or be documented as being
> requried (and ASSERT_RTNL() added here.)
>
> The reason is that sfp_dev is the SFP socket device which can be
> unbound via sfp_unregister_socket(), which will set bus->sfp_dev to
> NULL. This could race with the above.
>

That's right, I'll add an assert and document it, thanks for spotting
this.

Maxime

\
 
 \ /
  Last update: 2023-11-23 14:36    [W:0.332 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site