Make it atomic for the devfs_populate_loop() to see the setting of

SI_ALIAS flag and initialization of the si_parent when alias is created.
Assert that supplied parent device is not NULL.

Both situations could cause NULL dereference in the
devfs_populate_loop() when creating a symlink for SI_ALIAS'ed device.
Namely, cdp->cdp_c.si_parent may be NULL.

Reported by:	mav
MFC after:	2 weeks
This commit is contained in:
Konstantin Belousov 2008-07-11 11:22:19 +00:00
parent 5692c36098
commit ae95dc623a

View File

@ -780,6 +780,7 @@ make_dev_alias(struct cdev *pdev, const char *fmt, ...)
va_list ap; va_list ap;
int i; int i;
KASSERT(pdev != NULL, ("NULL pdev"));
dev = devfs_alloc(); dev = devfs_alloc();
dev_lock(); dev_lock();
dev->si_flags |= SI_ALIAS; dev->si_flags |= SI_ALIAS;
@ -793,9 +794,9 @@ make_dev_alias(struct cdev *pdev, const char *fmt, ...)
va_end(ap); va_end(ap);
devfs_create(dev); devfs_create(dev);
dev_dependsl(pdev, dev);
clean_unrhdrl(devfs_inos); clean_unrhdrl(devfs_inos);
dev_unlock(); dev_unlock();
dev_depends(pdev, dev);
notify_create(dev); notify_create(dev);