Re: [PATCH 01/11] watchdog: WatchDog Timer Driver Core - Add basic framework

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Lars-Peter,

> >>> +int watchdog_dev_unregister(struct watchdog_device *watchdog)
> >>> +{
> >>> +	/* Check that a watchdog device was registered in the past */
> >>> +	if (!test_bit(0, &watchdog_dev_busy) || !wdd)
> >>> +		return -ENODEV;
> >>> +
> >>> +	/* We can only unregister the watchdog device that was registered */
> >>> +	if (watchdog != wdd) {
> >>> +		pr_err("%s: watchdog was not registered as /dev/watchdog.\n",
> >>> +			watchdog->info->identity);
> >>> +		return -ENODEV;
> >>> +	}
> >>> +
> >>> +	/* Unregister the miscdevice */
> >>> +	misc_deregister(&watchdog_miscdev);
> >>> +	wdd = NULL;
> >>> +	clear_bit(0, &watchdog_dev_busy);
> >>> +	return 0;
> >>> +}
> >>
> >> What happens if the watchdog gets unregistered if the device is still opened?
> >> Even though if you'd check wdd for not being NULL in the file callbacks there
> >> is still a chance for races if the devices is unregistered at the same time as
> >> the callback is running. You'd either need a big lock to protect from having a
> >> file callback and unregister running concurrently or add ref-counting to the
> >> watchdog_device, the later best done by embedding a struct device and using the
> >> device driver model.
> > 
> > You cannot unload the watchdog-drivers module if /dev/watchdog is still open.
> > So if the watchdog_unregister function is in the exit function of the module
> > then we are safe. But I think you have a point if that is not the case.
> > Solution would be to return an error when the watchdog_unregister_device routine
> > is called and the WDOG_DEV_OPEN bit is set. Will create an extra patch for that.
> > 
> 
> The problem is, that this doesn't fit nicely into the linux device driver
> model, because it doesn't allow the removal of a device to fail. So you'll
> still end of with undefined behavior.

It's not an issue now. But we will indeed have to tackle it, when we start using
the device driver model.

Kind regards,
Wim.

--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux