[PATCH] media: dvb: Add error handling for bcm3510_writeB()

Wentao Liang posted 1 patch 7 months, 3 weeks ago
drivers/media/dvb-frontends/bcm3510.c | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
[PATCH] media: dvb: Add error handling for bcm3510_writeB()
Posted by Wentao Liang 7 months, 3 weeks ago
In bcm3510_bert_reset(), the function performed multiple writes
without checking the return value of bcm3510_writeB(). Since almost
all the bcm3510_writeB() in this driver have check their return
value, it is necessary to add an error check for the bcm3510_writeB()
in bcm3510_bert_reset().

And the returned error code of bcm3510_bert_reset() is ignored in
bcm3510_set_frontend().

Add error checking for each bcm3510_writeB() and propagate any
errors immediately in bcm3510_bert_reset().

Add error handling for bcm3510_bert_reset() in bcm3510_set_frontend().

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 | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/drivers/media/dvb-frontends/bcm3510.c b/drivers/media/dvb-frontends/bcm3510.c
index d935fb10e620..fe89d46cca1d 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;
@@ -566,7 +578,9 @@ static int bcm3510_set_frontend(struct dvb_frontend *fe)
 	bcm3510_do_hab_cmd(st, CMD_STATE_CONTROL, MSGID_BERT_CONTROL, (u8 *) &bert, sizeof(bert), NULL, 0);
 	bcm3510_do_hab_cmd(st, CMD_STATE_CONTROL, MSGID_BERT_SET, (u8 *) &bert, sizeof(bert), NULL, 0);
 
-	bcm3510_bert_reset(st);
+	ret = bcm3510_bert_reset(st);
+	if (ret < 0)
+		return ret;
 
 	ret = bcm3510_set_freq(st, c->frequency);
 	if (ret < 0)
-- 
2.42.0.windows.2