watchdog: fix watchdog_set_device() when the default watchdog device is used
authorMichael Olbrich <m.olbrich@pengutronix.de>
Wed, 2 Feb 2022 14:26:53 +0000 (15:26 +0100)
committerMichael Olbrich <m.olbrich@pengutronix.de>
Fri, 4 Feb 2022 11:26:58 +0000 (12:26 +0100)
commitf4b1a6b6419b771d26342a9b75b1d77ee9d90133
treed4410962650d6ab9bc5175795751913264378611
parent2b560c6e545346e9791962e37361ca044fca036e
watchdog: fix watchdog_set_device() when the default watchdog device is used

If watchdog_set_device() is not called before open_watchdog() then
'watchdog_device' remains 'NULL' while the device is open.

As a result, the "same device" check in watchdog_set_device() does not work
correctly: If no device is specified (e.g. from watchdog_free_device())
then the current fd is not closed.

Fix this by setting 'watchdog_device' to the correct device during
open_watchdog()
src/shared/watchdog.c