stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: dvb: Add error checking for bcm3510_writeB()
@ 2025-04-01  4:11 Wentao Liang
  2025-04-07  2:11 ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2025-04-01  4:11 UTC (permalink / raw)
  To: mchehab
  Cc: yujiaoliang, hverkuil, linux-media, linux-kernel, Wentao Liang,
	stable

In  bcm3510_bert_reset(), the function performed multiple writes
without checking the return value of bcm3510_writeB(). This could
result in silent failures if the writes failed, leaving the BER
counter in an undefined state.

Add error checking for each bcm3510_writeB call and propagate any
errors immediately. This ensures proper error handling and prevents
silent failures during BER counter initialization.

Fixes: 55f51efdb696 ("[PATCH] dvb: flexcop: add BCM3510 ATSC frontend support for Air2PC card")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/media/dvb-frontends/bcm3510.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/media/dvb-frontends/bcm3510.c b/drivers/media/dvb-frontends/bcm3510.c
index d935fb10e620..fc5853fc9595 100644
--- a/drivers/media/dvb-frontends/bcm3510.c
+++ b/drivers/media/dvb-frontends/bcm3510.c
@@ -270,10 +270,18 @@ static int bcm3510_bert_reset(struct bcm3510_state *st)
 	if ((ret = bcm3510_readB(st,0xfa,&b)) < 0)
 		return ret;
 
-	b.BERCTL_fa.RESYNC = 0; bcm3510_writeB(st,0xfa,b);
-	b.BERCTL_fa.RESYNC = 1; bcm3510_writeB(st,0xfa,b);
-	b.BERCTL_fa.RESYNC = 0; bcm3510_writeB(st,0xfa,b);
-	b.BERCTL_fa.CNTCTL = 1; b.BERCTL_fa.BITCNT = 1; bcm3510_writeB(st,0xfa,b);
+	b.BERCTL_fa.RESYNC = 0;
+	if ((ret = bcm3510_writeB(st,0xfa,b)) < 0)
+		return ret;
+	b.BERCTL_fa.RESYNC = 1;
+	if ((ret = bcm3510_writeB(st,0xfa,b)) < 0)
+		return ret;
+	b.BERCTL_fa.RESYNC = 0;
+	if ((ret = bcm3510_writeB(st,0xfa,b)) < 0)
+		return ret;
+	b.BERCTL_fa.CNTCTL = 1; b.BERCTL_fa.BITCNT = 1;
+	if ((ret = bcm3510_writeB(st,0xfa,b)) < 0)
+		return ret;
 
 	/* clear residual bit counter TODO  */
 	return 0;
-- 
2.42.0.windows.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] media: dvb: Add error checking for bcm3510_writeB()
  2025-04-01  4:11 [PATCH] media: dvb: Add error checking for bcm3510_writeB() Wentao Liang
@ 2025-04-07  2:11 ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 2+ messages in thread
From: Mauro Carvalho Chehab @ 2025-04-07  2:11 UTC (permalink / raw)
  To: Wentao Liang
  Cc: mchehab, yujiaoliang, hverkuil, linux-media, linux-kernel, stable

Em Tue,  1 Apr 2025 12:11:41 +0800
Wentao Liang <vulab@iscas.ac.cn> escreveu:

> In  bcm3510_bert_reset(), the function performed multiple writes
> without checking the return value of bcm3510_writeB(). This could
> result in silent failures if the writes failed, leaving the BER
> counter in an undefined state.

Did you actually had an issue here with a real hardware? If do, please
describe what happened.

> 
> Add error checking for each bcm3510_writeB call and propagate any
> errors immediately. This ensures proper error handling and prevents
> silent failures during BER counter initialization.
> 
> Fixes: 55f51efdb696 ("[PATCH] dvb: flexcop: add BCM3510 ATSC frontend support for Air2PC card")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>  drivers/media/dvb-frontends/bcm3510.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/dvb-frontends/bcm3510.c b/drivers/media/dvb-frontends/bcm3510.c
> index d935fb10e620..fc5853fc9595 100644
> --- a/drivers/media/dvb-frontends/bcm3510.c
> +++ b/drivers/media/dvb-frontends/bcm3510.c
> @@ -270,10 +270,18 @@ static int bcm3510_bert_reset(struct bcm3510_state *st)
>  	if ((ret = bcm3510_readB(st,0xfa,&b)) < 0)
>  		return ret;
>  
> -	b.BERCTL_fa.RESYNC = 0; bcm3510_writeB(st,0xfa,b);
> -	b.BERCTL_fa.RESYNC = 1; bcm3510_writeB(st,0xfa,b);
> -	b.BERCTL_fa.RESYNC = 0; bcm3510_writeB(st,0xfa,b);
> -	b.BERCTL_fa.CNTCTL = 1; b.BERCTL_fa.BITCNT = 1; bcm3510_writeB(st,0xfa,b);
> +	b.BERCTL_fa.RESYNC = 0;
> +	if ((ret = bcm3510_writeB(st,0xfa,b)) < 0)
> +		return ret;
> +	b.BERCTL_fa.RESYNC = 1;
> +	if ((ret = bcm3510_writeB(st,0xfa,b)) < 0)
> +		return ret;
> +	b.BERCTL_fa.RESYNC = 0;
> +	if ((ret = bcm3510_writeB(st,0xfa,b)) < 0)
> +		return ret;
> +	b.BERCTL_fa.CNTCTL = 1; b.BERCTL_fa.BITCNT = 1;
> +	if ((ret = bcm3510_writeB(st,0xfa,b)) < 0)
> +		return ret;
>  
>  	/* clear residual bit counter TODO  */
>  	return 0;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-04-07  2:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-01  4:11 [PATCH] media: dvb: Add error checking for bcm3510_writeB() Wentao Liang
2025-04-07  2:11 ` Mauro Carvalho Chehab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).