media: mxl5007t: release tuner state when attach fails
Subsystems (3)
PATCH 1/1 media: mxl5007t: release tuner state when attach fails
mxl5007t_attach() takes a shared tuner instance with hybrid_tuner_request_state() but sets fe->tuner_priv only on success. When a register access fails during attach, mxl5007t_release() finds no tuner_priv and the instance stays on the global list, still pointing to the bridge's i2c adapter. Once the USB device is gone, the next mxl5007t_attach() walks the list and uses the freed adapter.
Set fe->tuner_priv right after hybrid_tuner_request_state(), as the other users of the helper do.
The bug was found, and the reproducer and this fix were written, by AI agents (Claude Mythos and Claude Opus models). The analysis and the patch were reviewed by a human.
---
A device that fails one tuner register access and then re-enumerates triggers it (KASAN, v7.3.1 and master 9d66f26fefac; clean with the fix). Reproducer available on request.
drivers/media/tuners/mxl5007t.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/tuners/mxl5007t.c +2 -2
@@ -844,6 +844,8 @@ struct dvb_frontend *mxl5007t_attach(struct dvb_frontend *fe, instance = hybrid_tuner_request_state(struct mxl5007t_state, state, hybrid_tuner_instance_list, i2c, addr,"mxl5007t" ); +/* let the fail path drop the reference taken above */ + fe->tuner_priv = state;switch (instance) {case 0 : goto fail;
@@ -893,8 +895,6 @@ struct dvb_frontend *mxl5007t_attach(struct dvb_frontend *fe,if (mxl_fail (ret)) goto fail; - fe->tuner_priv = state; -mutex_unlock (&mxl5007t_list_mutex); memcpy(&fe->ops.tuner_ops, &mxl5007t_tuner_ops,
Signature · 1 line
2.53.0