A DPLL device can be registered more than once. mlx5 does this when several functions of one NIC share a device. dpll_device_register() sends the create notification only on the first registration, but dpll_device_unregister() sends the delete notification on every unregistration. Removing one function then tells userspace that the device is gone while it is still registered and still listed by device-get. Send the delete notification only when the last registration goes away. Send it before that registration is removed, so the message can still be filled. Fixes: 9d71b54b65b1 ("dpll: netlink: Add DPLL framework base functions") Signed-off-by: Ivan Vecera --- drivers/dpll/dpll_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/dpll/dpll_core.c b/drivers/dpll/dpll_core.c index 277692d12d3d1e..c32e59f3e25afa 100644 --- a/drivers/dpll/dpll_core.c +++ b/drivers/dpll/dpll_core.c @@ -534,12 +534,14 @@ void dpll_device_unregister(struct dpll_device *dpll, mutex_lock(&dpll_lock); ASSERT_DPLL_REGISTERED(dpll); - dpll_device_delete_ntf(dpll); reg = dpll_device_registration_find(dpll, ops, priv); if (WARN_ON(!reg)) { mutex_unlock(&dpll_lock); return; } + /* The device goes away with its last registration */ + if (list_is_singular(&dpll->registration_list)) + dpll_device_delete_ntf(dpll); list_del(®->list); __dpll_device_put(dpll, ®->tracker); kfree(reg); base-commit: 7ed616970b652ae76d99a01b468588e491021648 -- 2.56.1