Re: net: Fix inconsistent teardown and release of private netdev state.

2017-07-10 Thread Cong Wang
On Sun, Jul 9, 2017 at 7:07 PM, Jason A. Donenfeld wrote: > On Sat, Jul 8, 2017 at 12:39 AM, Cong Wang wrote: >> On Thu, Jul 6, 2017 at 7:24 AM, Jason A. Donenfeld wrote: >>> list_add(&priv->list, &list_of_things); >>> >>> ret = register_netdevice(); // if ret is < 0, then destru

Re: net: Fix inconsistent teardown and release of private netdev state.

2017-07-09 Thread Jason A. Donenfeld
On Sat, Jul 8, 2017 at 12:39 AM, Cong Wang wrote: > On Thu, Jul 6, 2017 at 7:24 AM, Jason A. Donenfeld wrote: >> list_add(&priv->list, &list_of_things); >> >> ret = register_netdevice(); // if ret is < 0, then destruct above is >> automatically called >> >> // RACE WITH L

Re: net: Fix inconsistent teardown and release of private netdev state.

2017-07-07 Thread Cong Wang
On Thu, Jul 6, 2017 at 7:24 AM, Jason A. Donenfeld wrote: > list_add(&priv->list, &list_of_things); > > ret = register_netdevice(); // if ret is < 0, then destruct above is > automatically called > > // RACE WITH LIST_ADD/LIST_DEL!! It's impossible to call list_add > only

Re: net: Fix inconsistent teardown and release of private netdev state.

2017-07-06 Thread Jason A. Donenfeld
On Thu, Jul 6, 2017 at 4:24 PM, Jason A. Donenfeld wrote: > > if (!ret) > pr_info("Yay it worked!\n"); > > return 0; This is supposed to be `return ret;`. See, even in psuedocode it's hard to get right.

Re: net: Fix inconsistent teardown and release of private netdev state.

2017-07-06 Thread Jason A. Donenfeld
Hey guys, I see why this priv_destructor patch is an acceptable bandaid for certain drivers, but I'm not exactly sure on the cleanest way of using it in new drivers. Check out the following psuedocode. Here's how error handling in newlink used to work before this patch: static void destruct(stru