On 08/17/2017 03:54 PM, Oliver Hartkopp wrote: > On 08/17/2017 03:17 PM, Marc Kleine-Budde wrote: > >> The code gets complicated, as during NETDEV_REGISTER the malloc may >> fail. But we can cancel the register with return >> notifier_from_errno(-ENOMEM); > > So this would lead to a netdevice completely failing to register then? > Nice! > >>> With NETDEV_REGISTER the memory would be allocated. Ok. >>> >>> An how would the memory be free'd then? >> >> NETDEV_UNREGISTER... But we have a problem, as j1939 needs per device >> memory, too. Which is kfree()ed in a NETDEV_UNREGISTER hook, too. The >> order of the hooks in not guaranteed. > > Yes. That's the same problem I was working around with > 'd->remove_on_zero_entries' %-/ Using proper refcounting ...but it gets quite complicatd with j1939. > Just to get an impression about the j1939 data structures: > > Would the per-device memory increase significantly when CAN_J1939 is > enabled? Or is it some array of pointers which would be added? An array with 256 members > struct addr_ent { > ktime_t rxtime; > struct j1939_ecu *ecu; > /* count users, to help transport protocol */ > int nusers; > } ents[256]; and some more stuff. Sums up to sizeof(priv)=4184 Byte on armv5 (32bit). Marc -- Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |