[PATCH v15 05/34] compositor-drm: Consistent failure paths for output creation
Pekka Paalanen
ppaalanen at gmail.com
Tue Feb 6 13:20:40 UTC 2018
On Mon, 5 Feb 2018 18:44:14 +0000
Daniel Stone <daniels at collabora.com> wrote:
> Rather than a smattering of error handlers, use consistent jump labels
> for error paths in create_output_for_connector().
>
> Signed-off-by: Daniel Stone <daniels at collabora.com>
> Reported-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
> ---
> libweston/compositor-drm.c | 21 ++++++++++++---------
> 1 file changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
> index 208a65dd3..5c3abee39 100644
> --- a/libweston/compositor-drm.c
> +++ b/libweston/compositor-drm.c
> @@ -4440,12 +4440,12 @@ create_output_for_connector(struct drm_backend *b,
> i = find_crtc_for_connector(b, resources, connector);
> if (i < 0) {
> weston_log("No usable crtc/encoder pair for connector.\n");
> - goto err;
> + goto err_init;
> }
>
> output = zalloc(sizeof *output);
> if (output == NULL)
> - goto err;
> + goto err_init;
>
> output->connector = connector;
> output->crtc_id = resources->crtcs[i];
> @@ -4472,7 +4472,7 @@ create_output_for_connector(struct drm_backend *b,
> DRM_MODE_OBJECT_CONNECTOR);
> if (!props) {
> weston_log("failed to get connector properties\n");
> - goto err;
scanout_plane issue.
> + goto err_output;
> }
> drm_property_info_populate(b, connector_props, output->props_conn,
> WDRM_CONNECTOR__COUNT, props);
> @@ -4497,8 +4497,8 @@ create_output_for_connector(struct drm_backend *b,
> for (i = 0; i < output->connector->count_modes; i++) {
> drm_mode = drm_output_add_mode(output, &output->connector->modes[i]);
> if (!drm_mode) {
> - drm_output_destroy(&output->base);
> - return -1;
> + weston_log("failed to add mode\n");
scanout_plane issue.
> + goto err_output;
> }
> }
>
> @@ -4508,8 +4508,7 @@ create_output_for_connector(struct drm_backend *b,
> if (!output->scanout_plane) {
> weston_log("Failed to find primary plane for output %s\n",
> output->base.name);
> - drm_output_destroy(&output->base);
> - return -1;
> + goto err_output;
This path cannot handle scanout_plane == NULL in drm_plane_destroy()
called by drm_output_destroy() in case of !universal_planes.
> }
>
> /* Failing to find a cursor plane is not fatal, as we'll fall back
> @@ -4522,9 +4521,13 @@ create_output_for_connector(struct drm_backend *b,
>
> return 0;
>
> -err:
> - drmModeFreeConnector(connector);
> +err_output:
> + drm_output_destroy(&output->base);
> + return -1;
> + /* no fallthrough! */
>
> +err_init:
> + drmModeFreeConnector(connector);
> return -1;
> }
>
Otherwise looks ok.
Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20180206/d0359485/attachment.sig>
More information about the wayland-devel
mailing list