diff mbox series

[v2] media: dvb: Add error checking for bcm3510_writeB()

Message ID 20250401064931.2104-1-vulab@iscas.ac.cn (mailing list archive)
State New
Headers show
Series [v2] media: dvb: Add error checking for bcm3510_writeB() | expand

Commit Message

Wentao Liang April 1, 2025, 6:49 a.m. UTC
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 | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/media/dvb-frontends/bcm3510.c b/drivers/media/dvb-frontends/bcm3510.c
index d935fb10e620..9e60020a8fea 100644
--- a/drivers/media/dvb-frontends/bcm3510.c
+++ b/drivers/media/dvb-frontends/bcm3510.c
@@ -270,10 +270,22 @@  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;
+	ret = bcm3510_writeB(st, 0xfa, b);
+	if (ret < 0)
+		return ret;
+	b.BERCTL_fa.RESYNC = 1;
+	ret = bcm3510_writeB(st, 0xfa, b);
+	if (ret < 0)
+		return ret;
+	b.BERCTL_fa.RESYNC = 0;
+	ret = bcm3510_writeB(st, 0xfa, b);
+	if (ret < 0)
+		return ret;
+	b.BERCTL_fa.CNTCTL = 1; b.BERCTL_fa.BITCNT = 1;
+	ret = bcm3510_writeB(st, 0xfa, b);
+	if (ret < 0)
+		return ret;
 
 	/* clear residual bit counter TODO  */
 	return 0;