[PATCH] media: pci: hws: only init channels the device actually has

Linkai Gong posted 1 patch 1 month, 1 week ago
drivers/media/pci/hws/hws_pci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] media: pci: hws: only init channels the device actually has
Posted by Linkai Gong 1 month, 1 week ago
hws_probe() initializes max_channels (always 4) control handlers, but
register/unregister only walk cur_max_video_ch (1 or 2 on smaller
chips). The extra handlers are never freed.

Initialize the same number of channels that cleanup uses.

Fixes: ba07fd2f5742 ("media: pci: add AVMatrix HWS capture driver")
Signed-off-by: Linkai Gong <gonglinkai@kylinos.cn>
---
 drivers/media/pci/hws/hws_pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/pci/hws/hws_pci.c b/drivers/media/pci/hws/hws_pci.c
index 30bb7d34465b..87ba27877f29 100644
--- a/drivers/media/pci/hws/hws_pci.c
+++ b/drivers/media/pci/hws/hws_pci.c
@@ -441,7 +441,7 @@ static int hws_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
 	hws_init_video_sys(hws, false);
 
 	/* 5) Init channels (video state, locks, vb2, ctrls) */
-	for (i = 0; i < hws->max_channels; i++) {
+	for (i = 0; i < hws->cur_max_video_ch; i++) {
 		ret = hws_video_init_channel(hws, i);
 		if (ret) {
 			dev_err(&pdev->dev, "video channel init failed (ch=%d)\n", i);
-- 
2.25.1
Re: [PATCH] media: pci: hws: only init channels the device actually has
Posted by Ben Hoff 1 month, 1 week ago
Reviewed-by: Ben Hoff <hoff.benjamin.k@gmail.com>

On Wed, Aug 19, 2026 at 2:34 AM Linkai Gong <gonglinkai@kylinos.cn> wrote:
>
> hws_probe() initializes max_channels (always 4) control handlers, but
> register/unregister only walk cur_max_video_ch (1 or 2 on smaller
> chips). The extra handlers are never freed.
>
> Initialize the same number of channels that cleanup uses.
>
> Fixes: ba07fd2f5742 ("media: pci: add AVMatrix HWS capture driver")
> Signed-off-by: Linkai Gong <gonglinkai@kylinos.cn>
> ---
>  drivers/media/pci/hws/hws_pci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> diff --git a/drivers/media/pci/hws/hws_pci.c b/drivers/media/pci/hws/hws_pci.c
> index 30bb7d34465b..87ba27877f29 100644
> --- a/drivers/media/pci/hws/hws_pci.c
> +++ b/drivers/media/pci/hws/hws_pci.c
> @@ -441,7 +441,7 @@ static int hws_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id)
>         hws_init_video_sys(hws, false);
>
>         /* 5) Init channels (video state, locks, vb2, ctrls) */
> -       for (i = 0; i < hws->max_channels; i++) {
> +       for (i = 0; i < hws->cur_max_video_ch; i++) {
>                 ret = hws_video_init_channel(hws, i);
>                 if (ret) {
>                         dev_err(&pdev->dev, "video channel init failed (ch=%d)\n", i);
> --
> 2.25.1