mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-13 15:29:45 +03:00
android: camera_device: Fix null pointer dereference
Commit7532caa2c7
("android: camera_device: Reset config_ if Camera::configure() fails") reworked the configuration sequence to ensure that the CameraConfiguration pointers gets reset when configuration fails. This inadvertently causes a null pointer dereference, as the CameraStream constructor accesses the camera configuration through CameraDevice::cameraConfiguration() before the internal config_ pointer is set. Fix this by passing the configuration pointer explicitly to the CameraStream constructor. Fixes:7532caa2c7
("android: camera_device: Reset config_ if Camera::configure() fails") Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Tested-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Tested-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
This commit is contained in:
parent
d3fef99844
commit
1684c3f930
4 changed files with 7 additions and 10 deletions
|
@ -682,8 +682,8 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
|
||||||
config->addConfiguration(streamConfig.config);
|
config->addConfiguration(streamConfig.config);
|
||||||
|
|
||||||
for (auto &stream : streamConfig.streams) {
|
for (auto &stream : streamConfig.streams) {
|
||||||
streams_.emplace_back(this, stream.type, stream.stream,
|
streams_.emplace_back(this, config.get(), stream.type,
|
||||||
config->size() - 1);
|
stream.stream, config->size() - 1);
|
||||||
stream.stream->priv = static_cast<void *>(&streams_.back());
|
stream.stream->priv = static_cast<void *>(&streams_.back());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,10 +48,6 @@ public:
|
||||||
unsigned int id() const { return id_; }
|
unsigned int id() const { return id_; }
|
||||||
camera3_device_t *camera3Device() { return &camera3Device_; }
|
camera3_device_t *camera3Device() { return &camera3Device_; }
|
||||||
const std::shared_ptr<libcamera::Camera> &camera() const { return camera_; }
|
const std::shared_ptr<libcamera::Camera> &camera() const { return camera_; }
|
||||||
libcamera::CameraConfiguration *cameraConfiguration() const
|
|
||||||
{
|
|
||||||
return config_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string &maker() const { return maker_; }
|
const std::string &maker() const { return maker_; }
|
||||||
const std::string &model() const { return model_; }
|
const std::string &model() const { return model_; }
|
||||||
|
|
|
@ -39,10 +39,10 @@ LOG_DECLARE_CATEGORY(HAL)
|
||||||
* and buffer allocation.
|
* and buffer allocation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CameraStream::CameraStream(CameraDevice *const cameraDevice, Type type,
|
CameraStream::CameraStream(CameraDevice *const cameraDevice,
|
||||||
|
CameraConfiguration *config, Type type,
|
||||||
camera3_stream_t *camera3Stream, unsigned int index)
|
camera3_stream_t *camera3Stream, unsigned int index)
|
||||||
: cameraDevice_(cameraDevice),
|
: cameraDevice_(cameraDevice), config_(config), type_(type),
|
||||||
config_(cameraDevice->cameraConfiguration()), type_(type),
|
|
||||||
camera3Stream_(camera3Stream), index_(index)
|
camera3Stream_(camera3Stream), index_(index)
|
||||||
{
|
{
|
||||||
if (type_ == Type::Internal || type_ == Type::Mapped) {
|
if (type_ == Type::Internal || type_ == Type::Mapped) {
|
||||||
|
|
|
@ -110,7 +110,8 @@ public:
|
||||||
Internal,
|
Internal,
|
||||||
Mapped,
|
Mapped,
|
||||||
};
|
};
|
||||||
CameraStream(CameraDevice *const cameraDevice, Type type,
|
CameraStream(CameraDevice *const cameraDevice,
|
||||||
|
libcamera::CameraConfiguration *config, Type type,
|
||||||
camera3_stream_t *camera3Stream, unsigned int index);
|
camera3_stream_t *camera3Stream, unsigned int index);
|
||||||
|
|
||||||
Type type() const { return type_; }
|
Type type() const { return type_; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue