Message ID | 20201002114323.GA3296553@kroah.com |
---|---|
State | Changes Requested |
Delegated to: | David Miller |
Headers | show |
Series | [v2] net: hso: do not call unregister if not registered | expand |
From: Greg KH <gregkh@linuxfoundation.org> Date: Fri, 2 Oct 2020 13:43:23 +0200 > @@ -2366,7 +2366,8 @@ static void hso_free_net_device(struct hso_device *hso_dev, bool bailout) > > remove_net_device(hso_net->parent); > > - if (hso_net->net) > + if (hso_net->net && > + hso_net->net->reg_state == NETREG_REGISTERED) > unregister_netdev(hso_net->net); > > /* start freeing */ I really want to get out of the habit of drivers testing the internal netdev registration state to make decisions. Instead, please track this internally. You know if you registered the device or not, therefore use that to control whether you try to unregister it or not. Thank you.
On Sat, Oct 03, 2020 at 05:00:42PM -0700, David Miller wrote: > From: Greg KH <gregkh@linuxfoundation.org> > Date: Fri, 2 Oct 2020 13:43:23 +0200 > > > @@ -2366,7 +2366,8 @@ static void hso_free_net_device(struct hso_device *hso_dev, bool bailout) > > > > remove_net_device(hso_net->parent); > > > > - if (hso_net->net) > > + if (hso_net->net && > > + hso_net->net->reg_state == NETREG_REGISTERED) > > unregister_netdev(hso_net->net); > > > > /* start freeing */ > > I really want to get out of the habit of drivers testing the internal > netdev registration state to make decisions. > > Instead, please track this internally. You know if you registered the > device or not, therefore use that to control whether you try to > unregister it or not. Fair enough. Tuba, do you want to fix this up in this way, or do you recommend that someone else do it? thanks, greg k-h
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index 2bb28db89432..e6b56bdf691d 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c @@ -2366,7 +2366,8 @@ static void hso_free_net_device(struct hso_device *hso_dev, bool bailout) remove_net_device(hso_net->parent); - if (hso_net->net) + if (hso_net->net && + hso_net->net->reg_state == NETREG_REGISTERED) unregister_netdev(hso_net->net); /* start freeing */