From d87246de124e4a7939dee4b4b71248a52c9c6893 Mon Sep 17 00:00:00 2001 From: Ralph Metzler Date: Tue, 12 Dec 2017 10:19:52 +0100 Subject: [PATCH] throw a warning on double unlocks based on patch by Daniel Scheller --- frontends/stv0910.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontends/stv0910.c b/frontends/stv0910.c index 34f3397..85fb7ec 100644 --- a/frontends/stv0910.c +++ b/frontends/stv0910.c @@ -1210,10 +1210,15 @@ static int gate_ctrl(struct dvb_frontend *fe, int enable) stat = write_reg(state, state->nr ? RSTV0910_P2_I2CRPT : RSTV0910_P1_I2CRPT, i2crpt); + if (stat < 0) + if (!WARN_ON(!mutex_is_locked(&state->base->i2c_lock))) + mutex_unlock(&state->base->i2c_lock); + state->i2crpt = i2crpt; if (!enable) - mutex_unlock(&state->base->i2c_lock); + if (!WARN_ON(!mutex_is_locked(&state->base->i2c_lock))) + mutex_unlock(&state->base->i2c_lock); return stat; }