summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline/rkisp1
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-12-08 03:40:25 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-12-09 11:26:13 +0200
commitff2ee0174ca62ab4460adfe20049ed05f52615c5 (patch)
tree292907ad2f2cc3252d9027822a7024dce6a59021 /src/libcamera/pipeline/rkisp1
parent2795f333fce5f43a4239d8d40d34dde4e5caa6ca (diff)
libcamera: v4l2_subdevice: Return a unique pointer from fromEntityName()
The fromEntityName() function returns a pointer to a newly allocated V4L2Subdevice instance, which must be deleted by the caller. This opens the door to memory leaks. Return a unique pointer instead, which conveys the API semantics better than a sentence in the documentation. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Diffstat (limited to 'src/libcamera/pipeline/rkisp1')
-rw-r--r--src/libcamera/pipeline/rkisp1/rkisp1.cpp6
-rw-r--r--src/libcamera/pipeline/rkisp1/rkisp1_path.cpp3
-rw-r--r--src/libcamera/pipeline/rkisp1/rkisp1_path.h3
3 files changed, 5 insertions, 7 deletions
diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
index eaa10f9f..c34a30a9 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp
@@ -217,7 +217,7 @@ private:
int freeBuffers(Camera *camera);
MediaDevice *media_;
- V4L2Subdevice *isp_;
+ std::unique_ptr<V4L2Subdevice> isp_;
V4L2VideoDevice *param_;
V4L2VideoDevice *stat_;
@@ -599,8 +599,7 @@ CameraConfiguration::Status RkISP1CameraConfiguration::validate()
}
PipelineHandlerRkISP1::PipelineHandlerRkISP1(CameraManager *manager)
- : PipelineHandler(manager), isp_(nullptr), param_(nullptr),
- stat_(nullptr)
+ : PipelineHandler(manager), param_(nullptr), stat_(nullptr)
{
}
@@ -608,7 +607,6 @@ PipelineHandlerRkISP1::~PipelineHandlerRkISP1()
{
delete param_;
delete stat_;
- delete isp_;
}
/* -----------------------------------------------------------------------------
diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
index 3f77b1c1..e05d9dd6 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.cpp
@@ -24,14 +24,13 @@ RkISP1Path::RkISP1Path(const char *name, const Span<const PixelFormat> &formats,
const Size &minResolution, const Size &maxResolution)
: name_(name), running_(false), formats_(formats),
minResolution_(minResolution), maxResolution_(maxResolution),
- resizer_(nullptr), video_(nullptr), link_(nullptr)
+ video_(nullptr), link_(nullptr)
{
}
RkISP1Path::~RkISP1Path()
{
delete video_;
- delete resizer_;
}
bool RkISP1Path::init(MediaDevice *media)
diff --git a/src/libcamera/pipeline/rkisp1/rkisp1_path.h b/src/libcamera/pipeline/rkisp1/rkisp1_path.h
index 8f443e51..f06ac5a7 100644
--- a/src/libcamera/pipeline/rkisp1/rkisp1_path.h
+++ b/src/libcamera/pipeline/rkisp1/rkisp1_path.h
@@ -7,6 +7,7 @@
#ifndef __LIBCAMERA_PIPELINE_RKISP1_PATH_H__
#define __LIBCAMERA_PIPELINE_RKISP1_PATH_H__
+#include <memory>
#include <vector>
#include <libcamera/camera.h>
@@ -65,7 +66,7 @@ private:
const Size minResolution_;
const Size maxResolution_;
- V4L2Subdevice *resizer_;
+ std::unique_ptr<V4L2Subdevice> resizer_;
V4L2VideoDevice *video_;
MediaLink *link_;
};