From f41ced8f108cc80f16509b907cd7ac93944459bc Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Tue, 6 Jan 2009 14:40:40 -0800 Subject: Check fops_get() return value Several subsystem open handlers dereference the fops_get() return value without checking it for nullness. This opens a race condition between the open handler and module unloading. A module can be marked as being unloaded (MODULE_STATE_GOING) before its exit function is called and gets the chance to unregister the driver. During that window open handlers can still be called, and fops_get() will fail in try_module_get() and return a NULL pointer. This change checks the fops_get() return value and returns -ENODEV if NULL. Reported-by: Alan Jenkins Signed-off-by: Laurent Pinchart Acked-by: Takashi Iwai Cc: Al Viro Cc: Dave Airlie Acked-by: Mauro Carvalho Chehab Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- drivers/media/dvb/dvb-core/dvbdev.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/media/dvb') diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c index 65d6966..6a32680 100644 --- a/drivers/media/dvb/dvb-core/dvbdev.c +++ b/drivers/media/dvb/dvb-core/dvbdev.c @@ -79,6 +79,10 @@ static int dvb_device_open(struct inode *inode, struct file *file) file->private_data = dvbdev; old_fops = file->f_op; file->f_op = fops_get(dvbdev->fops); + if (file->f_op == NULL) { + file->f_op = old_fops; + goto fail; + } if(file->f_op->open) err = file->f_op->open(inode,file); if (err) { @@ -90,6 +94,7 @@ static int dvb_device_open(struct inode *inode, struct file *file) unlock_kernel(); return err; } +fail: up_read(&minor_rwsem); unlock_kernel(); return -ENODEV; -- cgit v1.1 From 9b4778f680aa79d838ae2be6ab958938f744ce5f Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Wed, 7 Jan 2009 14:42:41 -0800 Subject: trivial: replace last usages of __FUNCTION__ in kernel __FUNCTION__ is gcc-specific, use __func__ Signed-off-by: Harvey Harrison Acked-by: Mauro Carvalho Chehab Signed-off-by: Linus Torvalds --- drivers/media/dvb/frontends/lgdt3304.c | 10 +++++----- drivers/media/dvb/frontends/s921_module.c | 2 +- drivers/media/dvb/ttpci/budget-ci.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/media/dvb') diff --git a/drivers/media/dvb/frontends/lgdt3304.c b/drivers/media/dvb/frontends/lgdt3304.c index 469ace5..3bb0c43 100644 --- a/drivers/media/dvb/frontends/lgdt3304.c +++ b/drivers/media/dvb/frontends/lgdt3304.c @@ -42,7 +42,7 @@ static int i2c_write_demod_bytes (struct dvb_frontend *fe, __u8 *buf, int len) for (i=0; ii2c, &i2cmsgs, 1))<0) { - printk("%s i2c_transfer error %d\n", __FUNCTION__, err); + printk("%s i2c_transfer error %d\n", __func__, err); if (err < 0) return err; else @@ -73,7 +73,7 @@ static int lgdt3304_i2c_read_reg(struct dvb_frontend *fe, unsigned int reg) i2cmsgs[1].buf = &buf; if((ret = i2c_transfer(state->i2c, i2cmsgs, 2))<0) { - printk("%s i2c_transfer error %d\n", __FUNCTION__, ret); + printk("%s i2c_transfer error %d\n", __func__, ret); return ret; } @@ -94,7 +94,7 @@ static int lgdt3304_i2c_write_reg(struct dvb_frontend *fe, int reg, int val) }; ret = i2c_transfer(state->i2c, &i2cmsgs, 1); if (ret != 1) { - printk("%s i2c_transfer error %d\n", __FUNCTION__, ret); + printk("%s i2c_transfer error %d\n", __func__, ret); return ret; } @@ -238,7 +238,7 @@ static int lgdt3304_set_parameters(struct dvb_frontend *fe, struct dvb_frontend_ } if (err) { - printk("%s error setting modulation\n", __FUNCTION__); + printk("%s error setting modulation\n", __func__); } else { state->current_modulation = param->u.vsb.modulation; } @@ -305,7 +305,7 @@ static int lgdt3304_read_status(struct dvb_frontend *fe, fe_status_t *status) } break; default: - printk("%s unhandled modulation\n", __FUNCTION__); + printk("%s unhandled modulation\n", __func__); } diff --git a/drivers/media/dvb/frontends/s921_module.c b/drivers/media/dvb/frontends/s921_module.c index 3cbb9cb..892af8c 100644 --- a/drivers/media/dvb/frontends/s921_module.c +++ b/drivers/media/dvb/frontends/s921_module.c @@ -136,7 +136,7 @@ static int s921_write(void *dev, u8 reg, u8 val) { }; if((err = i2c_transfer(state->i2c, &i2cmsgs, 1))<0) { - printk("%s i2c_transfer error %d\n", __FUNCTION__, err); + printk("%s i2c_transfer error %d\n", __func__, err); if (err < 0) return err; else diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c index 3507463..4d2a5cf 100644 --- a/drivers/media/dvb/ttpci/budget-ci.c +++ b/drivers/media/dvb/ttpci/budget-ci.c @@ -1450,7 +1450,7 @@ static void frontend_init(struct budget_ci *budget_ci) if (budget_ci->budget.dvb_frontend) { if (dvb_attach(stb6100_attach, budget_ci->budget.dvb_frontend, &tt3200_stb6100_config, &budget_ci->budget.i2c_adap)) { if (!dvb_attach(lnbp21_attach, budget_ci->budget.dvb_frontend, &budget_ci->budget.i2c_adap, 0, 0)) { - printk("%s: No LNBP21 found!\n", __FUNCTION__); + printk("%s: No LNBP21 found!\n", __func__); dvb_frontend_detach(budget_ci->budget.dvb_frontend); budget_ci->budget.dvb_frontend = NULL; } -- cgit v1.1 From 072ce0c50983033d35c63314e2be849568f116c2 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 5 Jan 2009 01:19:06 -0300 Subject: V4L/DVB (10178): dvb_frontend: Fix some sparse warnings due to static symbols /home/v4l/master/v4l/dvb_frontend.c:838:19: warning: symbol 'dtv_cmds' was not declared. Should it be static? /home/v4l/master/v4l/dvb_frontend.c:1035:6: warning: symbol 'dtv_property_dump' was not declared. Should it be static? /home/v4l/master/v4l/dvb_frontend.c:1066:5: warning: symbol 'is_legacy_delivery_system' was not declared. Should it be static? /home/v4l/master/v4l/dvb_frontend.c:1080:6: warning: symbol 'dtv_property_cache_sync' was not declared. Should it be static? /home/v4l/master/v4l/dvb_frontend.c:1132:6: warning: symbol 'dtv_property_legacy_params_sync' was not declared. Should it be static? /home/v4l/master/v4l/dvb_frontend.c:1187:6: warning: symbol 'dtv_property_adv_params_sync' was not declared. Should it be static? /home/v4l/master/v4l/dvb_frontend.c:1222:6: warning: symbol 'dtv_property_cache_submit' was not declared. Should it be static? /home/v4l/master/v4l/dvb_frontend.c:1253:5: warning: symbol 'dtv_property_process_get' was not declared. Should it be static? /home/v4l/master/v4l/dvb_frontend.c:1362:5: warning: symbol 'dtv_property_process_set' was not declared. Should it be static? Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/dvb-core/dvb_frontend.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'drivers/media/dvb') diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c index 171f9ca..8434077 100644 --- a/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb/dvb-core/dvb_frontend.c @@ -824,7 +824,7 @@ static int dvb_frontend_check_parameters(struct dvb_frontend *fe, return 0; } -struct dtv_cmds_h dtv_cmds[] = { +static struct dtv_cmds_h dtv_cmds[] = { [DTV_TUNE] = { .name = "DTV_TUNE", .cmd = DTV_TUNE, @@ -962,7 +962,7 @@ struct dtv_cmds_h dtv_cmds[] = { }, }; -void dtv_property_dump(struct dtv_property *tvp) +static void dtv_property_dump(struct dtv_property *tvp) { int i; @@ -993,7 +993,7 @@ void dtv_property_dump(struct dtv_property *tvp) dprintk("%s() tvp.u.data = 0x%08x\n", __func__, tvp->u.data); } -int is_legacy_delivery_system(fe_delivery_system_t s) +static int is_legacy_delivery_system(fe_delivery_system_t s) { if((s == SYS_UNDEFINED) || (s == SYS_DVBC_ANNEX_AC) || (s == SYS_DVBC_ANNEX_B) || (s == SYS_DVBT) || (s == SYS_DVBS) || @@ -1007,7 +1007,8 @@ int is_legacy_delivery_system(fe_delivery_system_t s) * drivers can use a single set_frontend tuning function, regardless of whether * it's being used for the legacy or new API, reducing code and complexity. */ -void dtv_property_cache_sync(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) +static void dtv_property_cache_sync(struct dvb_frontend *fe, + struct dvb_frontend_parameters *p) { struct dtv_frontend_properties *c = &fe->dtv_property_cache; @@ -1059,7 +1060,7 @@ void dtv_property_cache_sync(struct dvb_frontend *fe, struct dvb_frontend_parame /* Ensure the cached values are set correctly in the frontend * legacy tuning structures, for the advanced tuning API. */ -void dtv_property_legacy_params_sync(struct dvb_frontend *fe) +static void dtv_property_legacy_params_sync(struct dvb_frontend *fe) { struct dtv_frontend_properties *c = &fe->dtv_property_cache; struct dvb_frontend_private *fepriv = fe->frontend_priv; @@ -1114,7 +1115,7 @@ void dtv_property_legacy_params_sync(struct dvb_frontend *fe) /* Ensure the cached values are set correctly in the frontend * legacy tuning structures, for the legacy tuning API. */ -void dtv_property_adv_params_sync(struct dvb_frontend *fe) +static void dtv_property_adv_params_sync(struct dvb_frontend *fe) { struct dtv_frontend_properties *c = &fe->dtv_property_cache; struct dvb_frontend_private *fepriv = fe->frontend_priv; @@ -1149,7 +1150,7 @@ void dtv_property_adv_params_sync(struct dvb_frontend *fe) } } -void dtv_property_cache_submit(struct dvb_frontend *fe) +static void dtv_property_cache_submit(struct dvb_frontend *fe) { struct dtv_frontend_properties *c = &fe->dtv_property_cache; @@ -1180,8 +1181,9 @@ static int dvb_frontend_ioctl_legacy(struct inode *inode, struct file *file, static int dvb_frontend_ioctl_properties(struct inode *inode, struct file *file, unsigned int cmd, void *parg); -int dtv_property_process_get(struct dvb_frontend *fe, struct dtv_property *tvp, - struct inode *inode, struct file *file) +static int dtv_property_process_get(struct dvb_frontend *fe, + struct dtv_property *tvp, + struct inode *inode, struct file *file) { int r = 0; @@ -1253,8 +1255,10 @@ int dtv_property_process_get(struct dvb_frontend *fe, struct dtv_property *tvp, return r; } -int dtv_property_process_set(struct dvb_frontend *fe, struct dtv_property *tvp, - struct inode *inode, struct file *file) +static int dtv_property_process_set(struct dvb_frontend *fe, + struct dtv_property *tvp, + struct inode *inode, + struct file *file) { int r = 0; struct dvb_frontend_private *fepriv = fe->frontend_priv; -- cgit v1.1 From ffbc5f88148ff77039a4269e3f945e8471b2e0bb Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Mon, 5 Jan 2009 01:34:20 -0300 Subject: V4L/DVB (10180): drivers/media: Fix a number of sparse warnings anysee.c:44:5: warning: symbol 'dvb_usb_anysee_delsys' was not declared. Should it be static? cx24116.c:378:3: warning: symbol 'CX24116_MODFEC_MODES' was not declared. Should it be static? stb0899_algo.c:57:5: warning: symbol 'stb0899_get_srate' was not declared. Should it be static? stb0899_algo.c:766:6: warning: symbol 'Log2Int' was not declared. Should it be static? stb0899_drv.c:137:20: warning: symbol 'stb0899_quant_tab' was not declared. Should it be static? stb0899_drv.c:180:20: warning: symbol 'stb0899_est_tab' was not declared. Should it be static? stb0899_drv.c:220:5: warning: symbol '_stb0899_read_reg' was not declared. Should it be static? budget-ci.c:1348:23: warning: symbol 'tt3200_stb6100_config' was not declared. Should it be static? /home/v4l/master/v4l/cx25840-core.c:190:6: warning: symbol 'cx25840_work_handler' was not declared. Should it be static? /home/v4l/master/v4l/m5602_s5k83a.c:116:6: warning: symbol 's5k83a_dump_registers' was not declared. Should it be static? Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/dvb-usb/anysee.c | 2 +- drivers/media/dvb/frontends/cx24116.c | 2 +- drivers/media/dvb/frontends/stb0899_algo.c | 4 ++-- drivers/media/dvb/frontends/stb0899_drv.c | 6 +++--- drivers/media/dvb/ttpci/budget-ci.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/media/dvb') diff --git a/drivers/media/dvb/dvb-usb/anysee.c b/drivers/media/dvb/dvb-usb/anysee.c index 5017f08..c6e7b42 100644 --- a/drivers/media/dvb/dvb-usb/anysee.c +++ b/drivers/media/dvb/dvb-usb/anysee.c @@ -41,7 +41,7 @@ static int dvb_usb_anysee_debug; module_param_named(debug, dvb_usb_anysee_debug, int, 0644); MODULE_PARM_DESC(debug, "set debugging level" DVB_USB_DEBUG_STATUS); -int dvb_usb_anysee_delsys; +static int dvb_usb_anysee_delsys; module_param_named(delsys, dvb_usb_anysee_delsys, int, 0644); MODULE_PARM_DESC(delsys, "select delivery mode (0=DVB-C, 1=DVB-T)"); DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr); diff --git a/drivers/media/dvb/frontends/cx24116.c b/drivers/media/dvb/frontends/cx24116.c index 4f514d3..28ad609 100644 --- a/drivers/media/dvb/frontends/cx24116.c +++ b/drivers/media/dvb/frontends/cx24116.c @@ -369,7 +369,7 @@ static int cx24116_set_inversion(struct cx24116_state *state, * Not all S2 mmodulation schemes are support and not all rates with * a scheme are support. Especially, no auto detect when in S2 mode. */ -struct cx24116_modfec { +static struct cx24116_modfec { fe_delivery_system_t delivery_system; fe_modulation_t modulation; fe_code_rate_t fec; diff --git a/drivers/media/dvb/frontends/stb0899_algo.c b/drivers/media/dvb/frontends/stb0899_algo.c index ced9b7a..83dc7e1 100644 --- a/drivers/media/dvb/frontends/stb0899_algo.c +++ b/drivers/media/dvb/frontends/stb0899_algo.c @@ -54,7 +54,7 @@ static u32 stb0899_calc_srate(u32 master_clk, u8 *sfr) * stb0899_get_srate * Get the current symbol rate */ -u32 stb0899_get_srate(struct stb0899_state *state) +static u32 stb0899_get_srate(struct stb0899_state *state) { struct stb0899_internal *internal = &state->internal; u8 sfr[3]; @@ -763,7 +763,7 @@ static void stb0899_dvbs2_config_csm_auto(struct stb0899_state *state) stb0899_write_s2reg(state, STB0899_S2DEMOD, STB0899_BASE_CSM_CNTRL1, STB0899_OFF0_CSM_CNTRL1, reg); } -long Log2Int(int number) +static long Log2Int(int number) { int i; diff --git a/drivers/media/dvb/frontends/stb0899_drv.c b/drivers/media/dvb/frontends/stb0899_drv.c index bee28f7..10613ac 100644 --- a/drivers/media/dvb/frontends/stb0899_drv.c +++ b/drivers/media/dvb/frontends/stb0899_drv.c @@ -134,7 +134,7 @@ static const struct stb0899_tab stb0899_dvbs2rf_tab[] = { }; /* DVB-S2 Es/N0 quant in dB/100 vs read value * 100*/ -struct stb0899_tab stb0899_quant_tab[] = { +static struct stb0899_tab stb0899_quant_tab[] = { { 0, 0 }, { 0, 100 }, { 600, 200 }, @@ -177,7 +177,7 @@ struct stb0899_tab stb0899_quant_tab[] = { }; /* DVB-S2 Es/N0 estimate in dB/100 vs read value */ -struct stb0899_tab stb0899_est_tab[] = { +static struct stb0899_tab stb0899_est_tab[] = { { 0, 0 }, { 0, 1 }, { 301, 2 }, @@ -217,7 +217,7 @@ struct stb0899_tab stb0899_est_tab[] = { { 5721, 526017 }, }; -int _stb0899_read_reg(struct stb0899_state *state, unsigned int reg) +static int _stb0899_read_reg(struct stb0899_state *state, unsigned int reg) { int ret; diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c index 3507463..16ef35a 100644 --- a/drivers/media/dvb/ttpci/budget-ci.c +++ b/drivers/media/dvb/ttpci/budget-ci.c @@ -1337,7 +1337,7 @@ static struct stb0899_config tt3200_config = { .tuner_set_rfsiggain = NULL }; -struct stb6100_config tt3200_stb6100_config = { +static struct stb6100_config tt3200_stb6100_config = { .tuner_address = 0x60, .refclock = 27000000, }; -- cgit v1.1 From 571d864c68d429a82fd61e97404a2de210ffc72d Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 6 Jan 2009 08:33:46 -0300 Subject: V4L/DVB (10189): dm1105: Fix build with INPUT=m and DVB_DM1105=y As reported by Randy Dunlap : With CONFIG_INPUT=m and CONFIG_DVB_DM1105=y: drivers/built-in.o: In function `input_sync': dm1105.c:(.text+0x120c33): undefined reference to `input_event' drivers/built-in.o: In function `dm1105_emit_key': dm1105.c:(.text+0x120c6c): undefined reference to `input_event' dm1105.c:(.text+0x120c82): undefined reference to `input_event' dm1105.c:(.text+0x120cb2): undefined reference to `input_event' dm1105.c:(.text+0x120cd1): undefined reference to `input_event' drivers/built-in.o: In function `dm1105_ir_init': (.devinit.text+0xd8ae): undefined reference to `input_allocate_device' drivers/built-in.o: In function `dm1105_ir_init': (.devinit.text+0xd9f6): undefined reference to `input_register_device' drivers/built-in.o: In function `dm1105_ir_init': (.devinit.text+0xda09): undefined reference to `input_free_device' drivers/built-in.o: In function `dm1105_ir_exit': (.devexit.text+0xcde): undefined reference to `input_unregister_device' This is due to the lack of a dependency between dm1105 and CONFIG_INPUT Cc: Igor M. Liplianin Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/dm1105/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/media/dvb') diff --git a/drivers/media/dvb/dm1105/Kconfig b/drivers/media/dvb/dm1105/Kconfig index 1332301..43f4d44 100644 --- a/drivers/media/dvb/dm1105/Kconfig +++ b/drivers/media/dvb/dm1105/Kconfig @@ -1,6 +1,7 @@ config DVB_DM1105 tristate "SDMC DM1105 based PCI cards" depends on DVB_CORE && PCI && I2C + depends on INPUT select DVB_PLL if !DVB_FE_CUSTOMISE select DVB_STV0299 if !DVB_FE_CUSTOMISE select DVB_STV0288 if !DVB_FE_CUSTOMISE -- cgit v1.1