Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] media: ipu6: Buffer leak in start_streaming error path bypassing out_return_buffers --
commit 05f370625cb57787ffdbece5abefcb5044316ff0 Author: Sakari Ailus sakari.ailus@linux.intel.com
media: ipu6: Remove need_reset check from video device open
The ISYS requires power reset in some cases. Opening a video node is however independent of that; allow opening it even if reset is needed.
diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c index 129016e57446b..44541aff79b30 100644 --- a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c +++ b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c @@ -109,23 +109,6 @@ const struct ipu6_isys_pixelformat ipu6_isys_pfmts[] = { IPU6_FW_ISYS_FRAME_FORMAT_RAW16, true }, };
-static int video_open(struct file *file) -{
- struct ipu6_isys_video *av = video_drvdata(file);
- struct ipu6_isys *isys = av->isys;
- struct ipu6_bus_device *adev = isys->adev;
- mutex_lock(&isys->mutex);
- if (isys->need_reset) {
mutex_unlock(&isys->mutex);dev_warn(&adev->auxdev.dev, "isys power cycle required\n");return -EIO;- }
- mutex_unlock(&isys->mutex);
- return v4l2_fh_open(file);
-}
[ ... ]
@@ -809,7 +792,7 @@ static const struct v4l2_file_operations isys_fops = { .poll = vb2_fop_poll, .unlocked_ioctl = video_ioctl2, .mmap = vb2_fop_mmap,
- .open = video_open,
- .open = v4l2_fh_open,
[Severity: High] Does removing the need_reset check from open expose a buffer leak in the start_streaming error path?
If the hardware requires a reset (isys->need_reset is true) when the user queues buffers via VIDIOC_QBUF, the buffers are added to aq->incoming. When the user then calls VIDIOC_STREAMON, start_streaming() in drivers/media/pci/intel/ipu6/ipu6-isys-queue.c returns directly without cleaning up the queued buffers:
scoped_guard(mutex, &av->isys->mutex) { if (av->isys->need_reset) return -EIO; }
Because this direct return bypasses the goto out_return_buffers error path, it skips returning the active buffers.
Does this leave the queued buffers orphaned in aq->incoming, resulting in a videobuf2 core warning and a use-after-free on subsequent queue operations or stream restart?