svn commit: r312005 - stable/11/sys/dev/etherswitch
Luiz Otavio O Souza
loos at FreeBSD.org
Fri Jan 13 03:08:07 UTC 2017
Author: loos
Date: Fri Jan 13 03:08:05 2017
New Revision: 312005
URL: https://svnweb.freebsd.org/changeset/base/312005
Log:
MFC r311700:
Convert etherswitch to use the make_dev_s(9) KPI. This fix a possible race
where si_drv1 can be accessed before it gets set.
Suggested by: kib
Sponsored by: Rubicon Communications, LLC (Netgate)
Modified:
stable/11/sys/dev/etherswitch/etherswitch.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/dev/etherswitch/etherswitch.c
==============================================================================
--- stable/11/sys/dev/etherswitch/etherswitch.c Fri Jan 13 03:05:44 2017 (r312004)
+++ stable/11/sys/dev/etherswitch/etherswitch.c Fri Jan 13 03:08:05 2017 (r312005)
@@ -99,17 +99,24 @@ etherswitch_probe(device_t dev)
static int
etherswitch_attach(device_t dev)
{
- struct etherswitch_softc *sc = (struct etherswitch_softc *)device_get_softc(dev);
+ int err;
+ struct etherswitch_softc *sc;
+ struct make_dev_args devargs;
+ sc = device_get_softc(dev);
sc->sc_dev = dev;
- sc->sc_devnode = make_dev(ðerswitch_cdevsw, device_get_unit(dev),
- UID_ROOT, GID_WHEEL,
- 0600, "etherswitch%d", device_get_unit(dev));
- if (sc->sc_devnode == NULL) {
+ make_dev_args_init(&devargs);
+ devargs.mda_devsw = ðerswitch_cdevsw;
+ devargs.mda_uid = UID_ROOT;
+ devargs.mda_gid = GID_WHEEL;
+ devargs.mda_mode = 0600;
+ devargs.mda_si_drv1 = sc;
+ err = make_dev_s(&devargs, &sc->sc_devnode, "etherswitch%d",
+ device_get_unit(dev));
+ if (err != 0) {
device_printf(dev, "failed to create character device\n");
return (ENXIO);
}
- sc->sc_devnode->si_drv1 = sc;
return (0);
}
More information about the svn-src-stable
mailing list