Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] Mantis: use dvb_attach to avoid double dereferencing on module removal

Convert the driver to use the dvb_attach macro to avoid the hard dependency
on the frontend drivers. The hard dependecy will result in loading a
number of unused frontends, and unwanted automatic dereferencing.

This fixes a bug where unloading the mantis driver will derefence any
attached frontend twice, which will cause an oops if the same frontend is
used by another driver.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Manu Abraham <manu@linuxtv.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Bjørn Mork and committed by
Mauro Carvalho Chehab
a22407fa 9c81496a

+12 -12
+1 -1
drivers/media/dvb/mantis/hopper_vp3028.c
··· 57 57 if (err == 0) { 58 58 msleep(250); 59 59 dprintk(MANTIS_ERROR, 1, "Probing for 10353 (DVB-T)"); 60 - fe = zl10353_attach(&hopper_vp3028_config, adapter); 60 + fe = dvb_attach(zl10353_attach, &hopper_vp3028_config, adapter); 61 61 62 62 if (!fe) 63 63 return -1;
+1 -1
drivers/media/dvb/mantis/mantis_vp1033.c
··· 173 173 msleep(250); 174 174 175 175 dprintk(MANTIS_ERROR, 1, "Probing for STV0299 (DVB-S)"); 176 - fe = stv0299_attach(&lgtdqcs001f_config, adapter); 176 + fe = dvb_attach(stv0299_attach, &lgtdqcs001f_config, adapter); 177 177 178 178 if (fe) { 179 179 fe->ops.tuner_ops.set_params = lgtdqcs001f_tuner_set;
+1 -1
drivers/media/dvb/mantis/mantis_vp1034.c
··· 82 82 msleep(250); 83 83 84 84 dprintk(MANTIS_ERROR, 1, "Probing for MB86A16 (DVB-S/DSS)"); 85 - fe = mb86a16_attach(&vp1034_mb86a16_config, adapter); 85 + fe = dvb_attach(mb86a16_attach, &vp1034_mb86a16_config, adapter); 86 86 if (fe) { 87 87 dprintk(MANTIS_ERROR, 1, 88 88 "found MB86A16 DVB-S/DSS frontend @0x%02x",
+3 -3
drivers/media/dvb/mantis/mantis_vp1041.c
··· 316 316 if (err == 0) { 317 317 mantis_frontend_soft_reset(mantis); 318 318 msleep(250); 319 - mantis->fe = stb0899_attach(&vp1041_stb0899_config, adapter); 319 + mantis->fe = dvb_attach(stb0899_attach, &vp1041_stb0899_config, adapter); 320 320 if (mantis->fe) { 321 321 dprintk(MANTIS_ERROR, 1, 322 322 "found STB0899 DVB-S/DVB-S2 frontend @0x%02x", 323 323 vp1041_stb0899_config.demod_address); 324 324 325 - if (stb6100_attach(mantis->fe, &vp1041_stb6100_config, adapter)) { 326 - if (!lnbp21_attach(mantis->fe, adapter, 0, 0)) 325 + if (dvb_attach(stb6100_attach, mantis->fe, &vp1041_stb6100_config, adapter)) { 326 + if (!dvb_attach(lnbp21_attach, mantis->fe, adapter, 0, 0)) 327 327 dprintk(MANTIS_ERROR, 1, "No LNBP21 found!"); 328 328 } 329 329 } else {
+2 -2
drivers/media/dvb/mantis/mantis_vp2033.c
··· 132 132 msleep(250); 133 133 134 134 dprintk(MANTIS_ERROR, 1, "Probing for CU1216 (DVB-C)"); 135 - fe = tda10021_attach(&vp2033_tda1002x_cu1216_config, 135 + fe = dvb_attach(tda10021_attach, &vp2033_tda1002x_cu1216_config, 136 136 adapter, 137 137 read_pwm(mantis)); 138 138 ··· 141 141 "found Philips CU1216 DVB-C frontend (TDA10021) @ 0x%02x", 142 142 vp2033_tda1002x_cu1216_config.demod_address); 143 143 } else { 144 - fe = tda10023_attach(&vp2033_tda10023_cu1216_config, 144 + fe = dvb_attach(tda10023_attach, &vp2033_tda10023_cu1216_config, 145 145 adapter, 146 146 read_pwm(mantis)); 147 147
+2 -2
drivers/media/dvb/mantis/mantis_vp2040.c
··· 132 132 msleep(250); 133 133 134 134 dprintk(MANTIS_ERROR, 1, "Probing for CU1216 (DVB-C)"); 135 - fe = tda10021_attach(&vp2040_tda1002x_cu1216_config, 135 + fe = dvb_attach(tda10021_attach, &vp2040_tda1002x_cu1216_config, 136 136 adapter, 137 137 read_pwm(mantis)); 138 138 ··· 141 141 "found Philips CU1216 DVB-C frontend (TDA10021) @ 0x%02x", 142 142 vp2040_tda1002x_cu1216_config.demod_address); 143 143 } else { 144 - fe = tda10023_attach(&vp2040_tda10023_cu1216_config, 144 + fe = dvb_attach(tda10023_attach, &vp2040_tda10023_cu1216_config, 145 145 adapter, 146 146 read_pwm(mantis)); 147 147
+2 -2
drivers/media/dvb/mantis/mantis_vp3030.c
··· 68 68 if (err == 0) { 69 69 msleep(250); 70 70 dprintk(MANTIS_ERROR, 1, "Probing for 10353 (DVB-T)"); 71 - fe = zl10353_attach(&mantis_vp3030_config, adapter); 71 + fe = dvb_attach(zl10353_attach, &mantis_vp3030_config, adapter); 72 72 73 73 if (!fe) 74 74 return -1; 75 75 76 - tda665x_attach(fe, &env57h12d5_config, adapter); 76 + dvb_attach(tda665x_attach, fe, &env57h12d5_config, adapter); 77 77 } else { 78 78 dprintk(MANTIS_ERROR, 1, "Frontend on <%s> POWER ON failed! <%d>", 79 79 adapter->name,