device: fix segfault when recreating devices
authorFelix Fietkau <nbd@nbd.name>
Mon, 17 Apr 2023 11:11:53 +0000 (13:11 +0200)
committerFelix Fietkau <nbd@nbd.name>
Mon, 17 Apr 2023 11:13:25 +0000 (13:13 +0200)
commit7de5440a520f9c6687358c7ef88ac4aad0ff98a5
tree1834e6eec859f8eb2e53a41d177031a6b73f011f
parent463a1207f0766417866e2c28316e58a96f84370b
device: fix segfault when recreating devices

Depending on the configuration, the callback on device_release could end up
deleting the device_dep from the list. If that happens, it must not be added
back to the recreated device, since that leads to use-after-free issues.
Check dep->dev before adding it back.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
device.c