]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/client: Do not free client memory by default
authorThomas Zimmermann <tzimmermann@suse.de>
Thu, 9 Oct 2025 13:16:31 +0000 (15:16 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Fri, 24 Oct 2025 06:45:37 +0000 (08:45 +0200)
Make no assumption on the allocation of the client's memory. For
example, amdgpu stores a client within another data structures,
where it cannot be freed by itself.

The correct place to free the client's memory is the client's free
callback. All existing clients implement this.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://lore.kernel.org/r/20251009132006.45834-5-tzimmermann@suse.de
drivers/gpu/drm/drm_client_event.c

index c3baeb4d4e6bcc1a97e005011d23195c8ec420fd..d25dc5250983ad9ebf1c3218985f7fdb233229c1 100644 (file)
@@ -39,12 +39,13 @@ void drm_client_dev_unregister(struct drm_device *dev)
        mutex_lock(&dev->clientlist_mutex);
        list_for_each_entry_safe(client, tmp, &dev->clientlist, list) {
                list_del(&client->list);
-               if (client->funcs && client->funcs->unregister) {
+               /*
+                * Unregistering consumes and frees the client.
+                */
+               if (client->funcs && client->funcs->unregister)
                        client->funcs->unregister(client);
-               } else {
+               else
                        drm_client_release(client);
-                       kfree(client);
-               }
        }
        mutex_unlock(&dev->clientlist_mutex);
 }