greybus: camera: Early update num_streams and flags

In configure_streams Operation, when returning from the greybus
operation call, we can assign the num_streams and flags variable earlier
so that if the following stream configuration inspection fails, the
caller receives the right number of configured streams anyway

Testing Done: White camera module preview and capture.
              Triggering failure during stream configuration inspection
              makes configuration fails, but avoid segfaulting as
              was previously happening

Signed-off-by: Jacopo Mondi <jacopo.mondi@linaro.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org>
Signed-off-by: Alex Elder <elder@linaro.org>
This commit is contained in:
Jacopo Mondi 2016-06-30 09:18:00 -05:00 committed by Alex Elder
parent e65579e335
commit 7f93eab7c7

View file

@ -432,6 +432,9 @@ static int gb_camera_configure_streams(struct gb_camera *gcam,
goto done;
}
*flags = resp->flags;
*num_streams = resp->num_streams;
for (i = 0; i < nstreams; ++i) {
struct gb_camera_stream_config_response *cfg = &resp->config[i];
@ -451,11 +454,8 @@ static int gb_camera_configure_streams(struct gb_camera *gcam,
}
if ((resp->flags & GB_CAMERA_CONFIGURE_STREAMS_ADJUSTED) ||
(*flags & GB_CAMERA_CONFIGURE_STREAMS_TEST_ONLY)) {
*flags = resp->flags;
*num_streams = resp->num_streams;
(req->flags & GB_CAMERA_CONFIGURE_STREAMS_TEST_ONLY))
goto done;
}
if (gcam->state == GB_CAMERA_STATE_CONFIGURED) {
gb_camera_teardown_data_connection(gcam);
@ -469,15 +469,14 @@ static int gb_camera_configure_streams(struct gb_camera *gcam,
gb_operation_sync(gcam->connection,
GB_CAMERA_TYPE_CONFIGURE_STREAMS,
req, req_size, resp, resp_size);
*flags = 0;
*num_streams = 0;
goto done;
}
gcam->state = GB_CAMERA_STATE_CONFIGURED;
}
*flags = resp->flags;
*num_streams = resp->num_streams;
done:
mutex_unlock(&gcam->mutex);
kfree(req);