提交 aa501be9 编写于 作者: C Chris Pascoe 提交者: Mauro Carvalho Chehab

V4L/DVB (6636): xc2028: protect device list

Protect refcount changes and modifications to xc2028_list with a mutex.
Signed-off-by: NChris Pascoe <c.pascoe@itee.uq.edu.au>
Signed-off-by: NMauro Carvalho Chehab <mchehab@infradead.org>
上级 91240dd9
...@@ -44,6 +44,8 @@ MODULE_PARM_DESC(audio_std, ...@@ -44,6 +44,8 @@ MODULE_PARM_DESC(audio_std,
"NICAM/B\n"); "NICAM/B\n");
static LIST_HEAD(xc2028_list); static LIST_HEAD(xc2028_list);
static DEFINE_MUTEX(xc2028_list_mutex);
/* struct for storing firmware table */ /* struct for storing firmware table */
struct firmware_description { struct firmware_description {
unsigned int type; unsigned int type;
...@@ -854,6 +856,8 @@ static int xc2028_dvb_release(struct dvb_frontend *fe) ...@@ -854,6 +856,8 @@ static int xc2028_dvb_release(struct dvb_frontend *fe)
tuner_dbg("%s called\n", __FUNCTION__); tuner_dbg("%s called\n", __FUNCTION__);
mutex_lock(&xc2028_list_mutex);
priv->count--; priv->count--;
if (!priv->count) { if (!priv->count) {
...@@ -865,6 +869,8 @@ static int xc2028_dvb_release(struct dvb_frontend *fe) ...@@ -865,6 +869,8 @@ static int xc2028_dvb_release(struct dvb_frontend *fe)
kfree(priv); kfree(priv);
} }
mutex_unlock(&xc2028_list_mutex);
return 0; return 0;
} }
...@@ -940,6 +946,8 @@ void *xc2028_attach(struct dvb_frontend *fe, struct xc2028_config *cfg) ...@@ -940,6 +946,8 @@ void *xc2028_attach(struct dvb_frontend *fe, struct xc2028_config *cfg)
video_dev = cfg->video_dev; video_dev = cfg->video_dev;
mutex_lock(&xc2028_list_mutex);
list_for_each_entry(priv, &xc2028_list, xc2028_list) { list_for_each_entry(priv, &xc2028_list, xc2028_list) {
if (priv->video_dev == cfg->video_dev) { if (priv->video_dev == cfg->video_dev) {
video_dev = NULL; video_dev = NULL;
...@@ -949,8 +957,10 @@ void *xc2028_attach(struct dvb_frontend *fe, struct xc2028_config *cfg) ...@@ -949,8 +957,10 @@ void *xc2028_attach(struct dvb_frontend *fe, struct xc2028_config *cfg)
if (video_dev) { if (video_dev) {
priv = kzalloc(sizeof(*priv), GFP_KERNEL); priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (priv == NULL) if (priv == NULL) {
mutex_unlock(&xc2028_list_mutex);
return NULL; return NULL;
}
priv->bandwidth = BANDWIDTH_6_MHZ; priv->bandwidth = BANDWIDTH_6_MHZ;
priv->need_load_generic = 1; priv->need_load_generic = 1;
...@@ -974,6 +984,8 @@ void *xc2028_attach(struct dvb_frontend *fe, struct xc2028_config *cfg) ...@@ -974,6 +984,8 @@ void *xc2028_attach(struct dvb_frontend *fe, struct xc2028_config *cfg)
tuner_info("type set to %s\n", "XCeive xc2028/xc3028 tuner"); tuner_info("type set to %s\n", "XCeive xc2028/xc3028 tuner");
mutex_unlock(&xc2028_list_mutex);
return fe; return fe;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册