Date: Thu, 27 Mar 2003 23:53:06 -0700 (MST) From: "M. Warner Losh" <imp@bsdimp.com> To: nate@root.org Cc: current@freebsd.org Subject: Re: Updated pci/if_* attach patches Message-ID: <20030327.235306.06521148.imp@bsdimp.com> In-Reply-To: <Pine.BSF.4.21.0303271519390.30498-100000@root.org> References: <Pine.BSF.4.21.0303271519390.30498-100000@root.org>
next in thread | previous in thread | raw e-mail | index | archive | help
In message: <Pine.BSF.4.21.0303271519390.30498-100000@root.org> Nate Lawson <nate@root.org> writes: : * Add bus_child_present check to calls to *_stop in the detach method for : devices that have children (i.e. miibus). bus_child_present isn't quite right for this. bus_child_present means "this child is still there in hardware" not "this node has children" + if (device_is_alive(dev)) { + if (bus_child_present(dev)) { + dc_stop(sc); + device_delete_child(dev, sc->dc_miibus); + } + ether_ifdetach(ifp); + bus_generic_detach(dev); + } should be just: + if (device_is_alive(dev)) { + if (bus_child_present(dev)) + dc_stop(sc); + device_delete_child(dev, sc->dc_miibus); + ether_ifdetach(ifp); + bus_generic_detach(dev); + } since it says 'if the card is still there, stop it' which is what you want in the cardbus case (and one day hotplug pci) since the card might not be there, in which case trying to do anything with it is doomed to failure. Please fix this issue before commit. # guess this is my fault for never writing a bus_child_present man # page :-( Also, on a stylistic note: - free(sc->dc_srom, M_DEVBUF); + if (sc->dc_srom) + free(sc->dc_srom, M_DEVBUF); The kernel free, just like its ANSI-89 userland counterpart, can tolerate free(NULL) now. I know some of the other frees check, some don't, but none should. I'd not hold up the commit on this issue, however. from kern_malloc.c: void free(addr, type) void *addr; struct malloc_type *type; { ... /* free(NULL, ...) does nothing */ if (addr == NULL) return; ... Warner
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030327.235306.06521148.imp>