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

From: Ben Hoff

Date: Thu Aug 20 2026 - 12:12:04 EST


Reviewed-by: Ben Hoff <hoff.benjamin.k@xxxxxxxxx>

On Wed, Aug 19, 2026 at 2:34 AM Linkai Gong <gonglinkai@xxxxxxxxxx> 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@xxxxxxxxxx>
> ---
> 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