From 33ba21e9e1baac2c1b2d4a01d7529daf1c7ce344 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Thu, 9 Oct 2025 15:16:29 +0200 Subject: drm/log: Do not hold lock across drm_client_release() When calling drm_client_release(), the client is already quiescent. Internal locks should therefore be dropped before the caller releases the client. In the case of the DRM log, concurrency originates from the console or from client events. The console has been unregistered in the previous line. The caller of the unregister callback, drm_log_client_unregister(), holds clientlist_mutex from struct drm_device to protect against concurrent client events. It is therefore safe to release the client without holding locks. Signed-off-by: Thomas Zimmermann Reviewed-by: Jocelyn Falempe > Link: https://lore.kernel.org/r/20251009132006.45834-3-tzimmermann@suse.de --- drivers/gpu/drm/clients/drm_log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/gpu/drm/clients/drm_log.c') diff --git a/drivers/gpu/drm/clients/drm_log.c b/drivers/gpu/drm/clients/drm_log.c index fd8556dd58ed..d040be2e9d7a 100644 --- a/drivers/gpu/drm/clients/drm_log.c +++ b/drivers/gpu/drm/clients/drm_log.c @@ -302,8 +302,8 @@ static void drm_log_client_unregister(struct drm_client_dev *client) mutex_lock(&dlog->lock); drm_log_free_scanout(client); - drm_client_release(client); mutex_unlock(&dlog->lock); + drm_client_release(client); kfree(dlog); drm_dbg(dev, "Unregistered with drm log\n"); } -- cgit From 52a023391662f5910077b1a9043b5b5f4d2f9b7b Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Thu, 9 Oct 2025 15:16:30 +0200 Subject: drm/log: Add free callback Free the client memory in the client free callback. Also move the debugging output into the free callback: drm_client_release() puts the reference on the DRM device, so pointers to the device should be considered dangling afterwards. Signed-off-by: Thomas Zimmermann Reviewed-by: Jocelyn Falempe > Link: https://lore.kernel.org/r/20251009132006.45834-4-tzimmermann@suse.de --- drivers/gpu/drm/clients/drm_log.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'drivers/gpu/drm/clients/drm_log.c') diff --git a/drivers/gpu/drm/clients/drm_log.c b/drivers/gpu/drm/clients/drm_log.c index d040be2e9d7a..24b08fdcb57a 100644 --- a/drivers/gpu/drm/clients/drm_log.c +++ b/drivers/gpu/drm/clients/drm_log.c @@ -293,19 +293,26 @@ static void drm_log_free_scanout(struct drm_client_dev *client) } } -static void drm_log_client_unregister(struct drm_client_dev *client) +static void drm_log_client_free(struct drm_client_dev *client) { struct drm_log *dlog = client_to_drm_log(client); struct drm_device *dev = client->dev; + kfree(dlog); + + drm_dbg(dev, "Unregistered with drm log\n"); +} + +static void drm_log_client_unregister(struct drm_client_dev *client) +{ + struct drm_log *dlog = client_to_drm_log(client); + unregister_console(&dlog->con); mutex_lock(&dlog->lock); drm_log_free_scanout(client); mutex_unlock(&dlog->lock); drm_client_release(client); - kfree(dlog); - drm_dbg(dev, "Unregistered with drm log\n"); } static int drm_log_client_hotplug(struct drm_client_dev *client) @@ -339,6 +346,7 @@ static int drm_log_client_resume(struct drm_client_dev *client) static const struct drm_client_funcs drm_log_client_funcs = { .owner = THIS_MODULE, + .free = drm_log_client_free, .unregister = drm_log_client_unregister, .hotplug = drm_log_client_hotplug, .suspend = drm_log_client_suspend, -- cgit