linux-mediatek.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH 03/11] net: devres: relax devm_register_netdev()
       [not found]     ` <CAMRc=MfF1RbQCJ62QhscFLu1HKYRc9M-2SMep1_vTJ2xhKjLAA@mail.gmail.com>
@ 2020-06-23 20:16       ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2020-06-23 20:16 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Andrew Lunn, linux-doc, Fabien Parent, Frank Rowand,
	Florian Fainelli, Jonathan Corbet, Russell King,
	Bartosz Golaszewski, intel-wired-lan, Jeff Kirsher, Mark Lee,
	devicetree, Stephane Le Provost, Sean Wang, Rob Herring,
	moderated list:ARM/Mediatek SoC...,
	John Crispin, Matthias Brugger, Linux ARM, netdev,
	Linux Kernel Mailing List, Andrew Perepech, Pedro Tsai,
	David S . Miller, Heiner Kallweit

On Tue, 23 Jun 2020 11:12:24 +0200 Bartosz Golaszewski wrote:
> wt., 23 cze 2020 o 00:49 Jakub Kicinski <kuba@kernel.org> napisał(a):
> > On Mon, 22 Jun 2020 12:00:48 +0200 Bartosz Golaszewski wrote:  
> > > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > >
> > > This devres helper registers a release callback that only unregisters
> > > the net_device. It works perfectly fine with netdev structs that are
> > > not managed on their own. There's no reason to check this - drop the
> > > warning.
> > >
> > > Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>  
> >
> > I think the reasoning for this suggestion was to catch possible UAF
> > errors. The netdev doesn't necessarily has to be from devm_alloc_*
> > but it has to be part of devm-ed memory or memory which is freed
> > after driver's remove callback.
> >  
> 
> Yes I understand that UAF was the concern here, but this limitation is
> unnecessary. In its current form devm_register_netdev() only works for
> struct net_device allocated with devm_alloc_etherdev(). Meanwhile
> calling alloc_netdev() (which doesn't have its devm counterpart yet -
> I may look into it shortly),

If resource managed alloc_netdev() is needed devm_alloc_netdev() can
be created, and even reuse devm_free_netdev() so no changes to the
warning are even necessary for such extension.

> then registering a devm action with devm_add_action_or_reset() which
> would free this memory is a perfectly fine use case. This patch would
> make it possible.

alloc_netdev() + devm_add_action makes no sense in the upstream kernel,
just add the appropriate helper, we care little about out of tree code.

> > Are there cases in practice where you've seen the netdev not being
> > devm allocated?  
> 
> As I said above - alloc_netdev() used by wireless, can, usb etc.
> drivers doesn't have a devres variant.



_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH 06/11] phy: un-inline devm_mdiobus_register()
       [not found]   ` <39e761f3-6607-d209-61df-535330f50db3@gmail.com>
@ 2020-06-25  9:16     ` Bartosz Golaszewski
  0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2020-06-25  9:16 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Andrew Lunn, linux-doc, Fabien Parent, Frank Rowand,
	Jonathan Corbet, Russell King, Bartosz Golaszewski,
	intel-wired-lan, Jeff Kirsher, Jakub Kicinski, Mark Lee,
	devicetree, Realtek linux nic maintainers, Stephane Le Provost,
	Sean Wang, Rob Herring, moderated list:ARM/Mediatek SoC...,
	John Crispin, Matthias Brugger, Linux ARM, netdev,
	Linux Kernel Mailing List, Andrew Perepech, Pedro Tsai,
	David S . Miller, Heiner Kallweit

On Tue, Jun 23, 2020 at 1:55 AM Florian Fainelli <f.fainelli@gmail.com> wrote:
>
> On 6/22/20 3:00 AM, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> >
> > Functions should only be static inline if they're very short. This
> > devres helper is already over 10 lines and it will grow soon as we'll
> > be improving upon its approach. Pull it into mdio_devres.c.
> >
> > Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
> > ---
> >  drivers/net/phy/Makefile      |  2 +-
> >  drivers/net/phy/mdio_devres.c | 18 ++++++++++++++++++
> >  include/linux/phy.h           | 15 ++-------------
> >  3 files changed, 21 insertions(+), 14 deletions(-)
> >  create mode 100644 drivers/net/phy/mdio_devres.c
>
> This would likely require an update to the MAINTAINERS file for this new
> file to be picked up by the correct entry.

It's already included in drivers/net/phy/ in the ETHERNET PHY LIBRARY entry.

Bartosz

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-25  9:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20200622100056.10151-1-brgl@bgdev.pl>
     [not found] ` <20200622100056.10151-4-brgl@bgdev.pl>
     [not found]   ` <20200622154943.02782b5a@kicinski-fedora-PC1C0HJN>
     [not found]     ` <CAMRc=MfF1RbQCJ62QhscFLu1HKYRc9M-2SMep1_vTJ2xhKjLAA@mail.gmail.com>
2020-06-23 20:16       ` [PATCH 03/11] net: devres: relax devm_register_netdev() Jakub Kicinski
     [not found] ` <20200622100056.10151-7-brgl@bgdev.pl>
     [not found]   ` <39e761f3-6607-d209-61df-535330f50db3@gmail.com>
2020-06-25  9:16     ` [PATCH 06/11] phy: un-inline devm_mdiobus_register() Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).