* [PATCH] gpu: host1x: Cleanup on initialization failure
@ 2017-11-27 10:11 Thierry Reding
0 siblings, 0 replies; only message in thread
From: Thierry Reding @ 2017-11-27 10:11 UTC (permalink / raw)
To: Thierry Reding, Mikko Perttunen
Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
linux-tegra-u79uwXL29TY76Z2rM5mHXA
From: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
When an error happens during the initialization of one of the sub-
devices, make sure to properly cleanup all sub-devices that have been
initialized up to that point.
Signed-off-by: Thierry Reding <treding-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
drivers/gpu/host1x/bus.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c
index 2e57c9cea696..88a3558b7916 100644
--- a/drivers/gpu/host1x/bus.c
+++ b/drivers/gpu/host1x/bus.c
@@ -211,8 +211,7 @@ int host1x_device_init(struct host1x_device *device)
dev_err(&device->dev,
"failed to initialize %s: %d\n",
dev_name(client->dev), err);
- mutex_unlock(&device->clients_lock);
- return err;
+ goto teardown;
}
}
}
@@ -220,6 +219,14 @@ int host1x_device_init(struct host1x_device *device)
mutex_unlock(&device->clients_lock);
return 0;
+
+teardown:
+ list_for_each_entry_continue_reverse(client, &device->clients, list)
+ if (client->ops->exit)
+ client->ops->exit(client);
+
+ mutex_unlock(&device->clients_lock);
+ return err;
}
EXPORT_SYMBOL(host1x_device_init);
--
2.15.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-11-27 10:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-27 10:11 [PATCH] gpu: host1x: Cleanup on initialization failure Thierry Reding
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).