diff options
author | Chris Pascoe <c.pascoe@itee.uq.edu.au> | 2007-11-19 17:45:38 +1000 |
---|---|---|
committer | Chris Pascoe <c.pascoe@itee.uq.edu.au> | 2007-11-19 17:45:38 +1000 |
commit | 350b7f1d6dc3515c775d3a399a54f49f60936de2 (patch) | |
tree | 77fc266e835cbb52657592bd00f767301bb9d1d8 /linux/drivers | |
parent | 40a29b32793e052ab3e29da080a2b9bf15eff148 (diff) | |
download | mediapointer-dvb-s2-350b7f1d6dc3515c775d3a399a54f49f60936de2.tar.gz mediapointer-dvb-s2-350b7f1d6dc3515c775d3a399a54f49f60936de2.tar.bz2 |
xc2028: protect device list
From: Chris Pascoe <c.pascoe@itee.uq.edu.au>
Protect refcount changes and modifications to xc2028_list with a mutex.
Signed-off-by: Chris Pascoe <c.pascoe@itee.uq.edu.au>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'linux/drivers')
-rw-r--r-- | linux/drivers/media/video/tuner-xc2028.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/linux/drivers/media/video/tuner-xc2028.c b/linux/drivers/media/video/tuner-xc2028.c index 3f0203b7a..a4bd6312f 100644 --- a/linux/drivers/media/video/tuner-xc2028.c +++ b/linux/drivers/media/video/tuner-xc2028.c @@ -55,6 +55,8 @@ MODULE_PARM_DESC(audio_std, "NICAM/B\n"); static LIST_HEAD(xc2028_list); +static DEFINE_MUTEX(xc2028_list_mutex); + /* struct for storing firmware table */ struct firmware_description { unsigned int type; @@ -871,6 +873,8 @@ static int xc2028_dvb_release(struct dvb_frontend *fe) tuner_dbg("%s called\n", __FUNCTION__); + mutex_lock(&xc2028_list_mutex); + priv->count--; if (!priv->count) { @@ -882,6 +886,8 @@ static int xc2028_dvb_release(struct dvb_frontend *fe) kfree(priv); } + mutex_unlock(&xc2028_list_mutex); + return 0; } @@ -962,6 +968,8 @@ void *xc2028_attach(struct dvb_frontend *fe, struct xc2028_config *cfg) video_dev = cfg->video_dev; + mutex_lock(&xc2028_list_mutex); + list_for_each_entry(priv, &xc2028_list, xc2028_list) { if (priv->video_dev == cfg->video_dev) { video_dev = NULL; @@ -971,8 +979,10 @@ void *xc2028_attach(struct dvb_frontend *fe, struct xc2028_config *cfg) if (video_dev) { priv = kzalloc(sizeof(*priv), GFP_KERNEL); - if (priv == NULL) + if (priv == NULL) { + mutex_unlock(&xc2028_list_mutex); return NULL; + } priv->bandwidth = BANDWIDTH_6_MHZ; priv->need_load_generic = 1; @@ -996,6 +1006,8 @@ void *xc2028_attach(struct dvb_frontend *fe, struct xc2028_config *cfg) tuner_info("type set to %s\n", "XCeive xc2028/xc3028 tuner"); + mutex_unlock(&xc2028_list_mutex); + return fe; } |