From: sashiko-bot@kernel.org
To: "Valery Borovsky" <vebohr@gmail.com>
Cc: linux-sunxi@lists.linux.dev
Subject: Re: [PATCH 1/6] media: airspy: Return queued buffers on start_streaming() failure
Date: Tue, 12 May 2026 22:17:08 +0000 [thread overview]
Message-ID: <20260512221708.BB82BC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <649601988189f031670215cb35add5e80439559d.1778518085.git.vebohr@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Disconnect during active streaming will inevitably cause a NULL pointer dereference in stop_streaming().
--
commit aad07499864faeab3c34f7bb9874675e7d87bb17
Author: Valery Borovsky <vebohr@gmail.com>
Subject: media: airspy: Return queued buffers on start_streaming() failure
The vb2 framework hands buffers to the driver via buf_queue() before
calling start_streaming(). If start_streaming() returns an error without
first returning those buffers via vb2_buffer_done(), the queued buffers
leak. This patch returns them on failure, including the device disconnect
case where start_streaming() previously exited early.
> diff --git a/drivers/media/usb/airspy/airspy.c b/drivers/media/usb/airspy/airspy.c
> index 8f6b721ba107c..57edb42463e81 100644
> --- a/drivers/media/usb/airspy/airspy.c
> +++ b/drivers/media/usb/airspy/airspy.c
> @@ -522,11 +522,13 @@ static int airspy_start_streaming(struct vb2_queue *vq, unsigned int count)
>
> dev_dbg(s->dev, "\n");
>
> - if (!s->udev)
> - return -ENODEV;
> -
> mutex_lock(&s->v4l2_lock);
>
> + if (!s->udev) {
> + ret = -ENODEV;
> + goto err_clear_bit;
> + }
> +
This isn't a regression introduced by this patch, but since we are handling
the disconnected state here, what happens if the physical USB device is
unplugged while streaming is already active?
If airspy_disconnect() runs and sets s->udev = NULL, and later the user
process closes the file descriptor triggering stream cleanup:
vb2_core_streamoff()
airspy_stop_streaming()
airspy_ctrl_msg(s, CMD_RECEIVER_MODE, 0, 0, NULL, 0)
usb_sndctrlpipe(s->udev, 0)
__create_pipe(dev, endpoint)
Could this unconditionally dereference the NULL s->udev pointer (accessing
dev->devnum) and cause a kernel oops?
Additionally, airspy_free_stream_bufs() is called immediately after:
airspy_stop_streaming()
...
airspy_free_stream_bufs(s)
usb_free_coherent(s->udev, ...)
Would passing the NULL s->udev pointer here also be problematic during
unplug?
Should there be a similar check for !s->udev in airspy_stop_streaming()
before attempting hardware communication and resource cleanup?
> s->sequence = 0;
>
> set_bit(POWER_ON, &s->flags);
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1778518085.git.vebohr@gmail.com?part=1
next prev parent reply other threads:[~2026-05-12 22:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 17:12 [PATCH 0/6] media: vb2: Return queued buffers from start_streaming() on error Valery Borovsky
2026-05-11 17:12 ` [PATCH 1/6] media: airspy: Return queued buffers on start_streaming() failure Valery Borovsky
2026-05-12 22:17 ` sashiko-bot [this message]
2026-05-11 17:12 ` [PATCH 2/6] media: msi2500: " Valery Borovsky
2026-05-11 17:12 ` [PATCH 3/6] media: pwc: " Valery Borovsky
2026-05-12 23:37 ` sashiko-bot
2026-05-11 17:12 ` [PATCH 4/6] media: rtl2832_sdr: " Valery Borovsky
2026-05-13 0:10 ` sashiko-bot
2026-05-11 17:12 ` [PATCH 5/6] media: stm32-dcmipp: " Valery Borovsky
2026-05-11 17:12 ` [PATCH 6/6] media: sun4i-csi: " Valery Borovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260512221708.BB82BC2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=sashiko@lists.linux.dev \
--cc=vebohr@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox