<div dir="ltr"><div>Apologies! This was not meant to be the patch I wanted to push. My brain has shut down for the weekend.</div><div>I'll push an update for the correct patch in reply to this one.</div><div><br></div><div>Naush</div><div><br></div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 28 Oct 2022 at 12:52, Naushir Patuck <<a href="mailto:naush@raspberrypi.com" target="_blank">naush@raspberrypi.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">releaseBuffers() unconditionally calls ioctl(REQBUFS, 0) to release device<br>
buffer allocations through the close() and class destructor functions. If<br>
another libcamera process is running concurrently with a different sensor, it<br>
would cause the ioctl to fail in the kernel because the buffer queue is owned<br>
owned by the other process. This in turn would cause libcamera to generate an<br>
error log message.<br>
<br>
Fix this by ensuring the releaseBuffers() only calls ioctl(REQBUFS, 0) if there<br>
have been buffers previously allocated by the device. This is done by testing<br>
the presense of the V4L2BufferCache in the object.<br>
<br>
Signed-off-by: Naushir Patuck <<a href="mailto:naush@raspberrypi.com" target="_blank">naush@raspberrypi.com</a>><br>
---<br>
src/libcamera/v4l2_videodevice.cpp | 3 +++<br>
1 file changed, 3 insertions(+)<br>
<br>
diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp<br>
index e30858c9fa02..ed446c25e45f 100644<br>
--- a/src/libcamera/v4l2_videodevice.cpp<br>
+++ b/src/libcamera/v4l2_videodevice.cpp<br>
@@ -1533,6 +1533,9 @@ int V4L2VideoDevice::importBuffers(unsigned int count)<br>
*/<br>
int V4L2VideoDevice::releaseBuffers()<br>
{<br>
+ if (!cache_)<br>
+ return;<br>
+<br>
LOG(V4L2, Debug) << "Releasing buffers";<br>
<br>
delete cache_;<br>
-- <br>
2.25.1<br>
<br>
</blockquote></div></div>