Commit 52a02339 authored by Thomas Zimmermann's avatar Thomas Zimmermann
Browse files

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: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarJocelyn Falempe <jfalempe@redhat.com&gt;>
Link: https://lore.kernel.org/r/20251009132006.45834-4-tzimmermann@suse.de
parent 33ba21e9
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -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,