* [PATCH v2] staging: most: video: prevent probes during component exit
@ 2025-11-26 15:59 Pavan Kumar Yalagada
2025-11-26 17:24 ` Greg KH
2025-11-26 17:48 ` Dan Carpenter
0 siblings, 2 replies; 3+ messages in thread
From: Pavan Kumar Yalagada @ 2025-11-26 15:59 UTC (permalink / raw)
To: parthiban.veerasooran, christian.gromm, gregkh
Cc: dan.carpenter, laurent.pinchart+renesas, hverkuil+cisco,
linux-staging, pavankumaryalagada
Previously, comp_probe_channel() would always add a new device to
video_devices, even if comp_exit() was running. This caused
BUG_ON(!list_empty(&video_devices)) in comp_exit() because
the list could be repopulated during teardown.
This patch adds a global static flag `comp_exiting`:
- Set `comp_exiting = true` at the start of comp_exit()
to signal shutdown.
- Check `comp_exiting` at the start of comp_probe_channel()
and return -EBUSY if set.
This prevents new devices from being added while the component
is exiting, ensuring video_devices stays empty and avoiding
BUG_ON triggers.
Signed-off-by: Pavan Kumar Yalagada <pavankumaryalagada@gmail.com>
---
drivers/staging/most/video/video.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c
index 32f71d9a9cf7..96366b7a0e29 100644
--- a/drivers/staging/most/video/video.c
+++ b/drivers/staging/most/video/video.c
@@ -60,6 +60,8 @@ static inline struct comp_fh *to_comp_fh(struct file *filp)
static LIST_HEAD(video_devices);
static DEFINE_SPINLOCK(list_lock);
+static bool comp_exiting;
+
static inline bool data_ready(struct most_video_dev *mdev)
{
return !list_empty(&mdev->pending_mbos);
@@ -453,6 +455,9 @@ static int comp_probe_channel(struct most_interface *iface, int channel_idx,
struct most_channel_config *ccfg, char *name,
char *args)
{
+ if (comp_exiting)
+ return -EBUSY;
+
int ret;
struct most_video_dev *mdev = get_comp_dev(iface, channel_idx);
@@ -553,6 +558,7 @@ static int __init comp_init(void)
static void __exit comp_exit(void)
{
+ comp_exiting = true;
struct most_video_dev *mdev, *tmp;
/*
@@ -575,7 +581,7 @@ static void __exit comp_exit(void)
most_deregister_configfs_subsys(&comp);
most_deregister_component(&comp);
- BUG_ON(!list_empty(&video_devices));
+ WARN_ON_ONCE(!list_empty(&video_devices));
}
module_init(comp_init);
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] staging: most: video: prevent probes during component exit
2025-11-26 15:59 [PATCH v2] staging: most: video: prevent probes during component exit Pavan Kumar Yalagada
@ 2025-11-26 17:24 ` Greg KH
2025-11-26 17:48 ` Dan Carpenter
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2025-11-26 17:24 UTC (permalink / raw)
To: Pavan Kumar Yalagada
Cc: parthiban.veerasooran, christian.gromm, dan.carpenter,
laurent.pinchart+renesas, hverkuil+cisco, linux-staging
On Wed, Nov 26, 2025 at 10:59:10AM -0500, Pavan Kumar Yalagada wrote:
> Previously, comp_probe_channel() would always add a new device to
> video_devices, even if comp_exit() was running. This caused
> BUG_ON(!list_empty(&video_devices)) in comp_exit() because
> the list could be repopulated during teardown.
>
> This patch adds a global static flag `comp_exiting`:
>
> - Set `comp_exiting = true` at the start of comp_exit()
> to signal shutdown.
> - Check `comp_exiting` at the start of comp_probe_channel()
> and return -EBUSY if set.
>
> This prevents new devices from being added while the component
> is exiting, ensuring video_devices stays empty and avoiding
> BUG_ON triggers.
>
> Signed-off-by: Pavan Kumar Yalagada <pavankumaryalagada@gmail.com>
> ---
> drivers/staging/most/video/video.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c
> index 32f71d9a9cf7..96366b7a0e29 100644
> --- a/drivers/staging/most/video/video.c
> +++ b/drivers/staging/most/video/video.c
> @@ -60,6 +60,8 @@ static inline struct comp_fh *to_comp_fh(struct file *filp)
> static LIST_HEAD(video_devices);
> static DEFINE_SPINLOCK(list_lock);
>
> +static bool comp_exiting;
> +
> static inline bool data_ready(struct most_video_dev *mdev)
> {
> return !list_empty(&mdev->pending_mbos);
> @@ -453,6 +455,9 @@ static int comp_probe_channel(struct most_interface *iface, int channel_idx,
> struct most_channel_config *ccfg, char *name,
> char *args)
> {
> + if (comp_exiting)
> + return -EBUSY;
This will not work at all.
Also, you need to properly document a v2 patch.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] staging: most: video: prevent probes during component exit
2025-11-26 15:59 [PATCH v2] staging: most: video: prevent probes during component exit Pavan Kumar Yalagada
2025-11-26 17:24 ` Greg KH
@ 2025-11-26 17:48 ` Dan Carpenter
1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-11-26 17:48 UTC (permalink / raw)
To: Pavan Kumar Yalagada
Cc: parthiban.veerasooran, christian.gromm, gregkh,
laurent.pinchart+renesas, hverkuil+cisco, linux-staging
On Wed, Nov 26, 2025 at 10:59:10AM -0500, Pavan Kumar Yalagada wrote:
> @@ -453,6 +455,9 @@ static int comp_probe_channel(struct most_interface *iface, int channel_idx,
> struct most_channel_config *ccfg, char *name,
> char *args)
> {
> + if (comp_exiting)
> + return -EBUSY;
> +
> int ret;
> struct most_video_dev *mdev = get_comp_dev(iface, channel_idx);
You've added this check above the declaration block which is ugly.
But what would happen if comp_exiting is false when we check here but
it's true by the time we get to the line which says:
list_add(&mdev->list, &video_devices);
There would still be a race.
>
> @@ -553,6 +558,7 @@ static int __init comp_init(void)
>
> static void __exit comp_exit(void)
> {
> + comp_exiting = true;
> struct most_video_dev *mdev, *tmp;
In front of the declaration block.
>
> /*
> @@ -575,7 +581,7 @@ static void __exit comp_exit(void)
>
> most_deregister_configfs_subsys(&comp);
> most_deregister_component(&comp);
> - BUG_ON(!list_empty(&video_devices));
> + WARN_ON_ONCE(!list_empty(&video_devices));
When the race condition is fixed, then we can just remove this.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-11-26 17:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-26 15:59 [PATCH v2] staging: most: video: prevent probes during component exit Pavan Kumar Yalagada
2025-11-26 17:24 ` Greg KH
2025-11-26 17:48 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox