Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=aa501be989f5df58c4732d5eb1989e5ca6479d90
Commit:     aa501be989f5df58c4732d5eb1989e5ca6479d90
Parent:     91240dd92474d4124f80b00e6200052b275a99a1
Author:     Chris Pascoe <[EMAIL PROTECTED]>
AuthorDate: Mon Nov 19 04:45:38 2007 -0300
Committer:  Mauro Carvalho Chehab <[EMAIL PROTECTED]>
CommitDate: Fri Jan 25 19:02:24 2008 -0200

    V4L/DVB (6636): xc2028: protect device list
    
    Protect refcount changes and modifications to xc2028_list with a mutex.
    
    Signed-off-by: Chris Pascoe <[EMAIL PROTECTED]>
    Signed-off-by: Mauro Carvalho Chehab <[EMAIL PROTECTED]>
---
 drivers/media/video/tuner-xc2028.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/drivers/media/video/tuner-xc2028.c 
b/drivers/media/video/tuner-xc2028.c
index a01231a..ac7f3e1 100644
--- a/drivers/media/video/tuner-xc2028.c
+++ b/drivers/media/video/tuner-xc2028.c
@@ -44,6 +44,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;
@@ -854,6 +856,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) {
@@ -865,6 +869,8 @@ static int xc2028_dvb_release(struct dvb_frontend *fe)
                kfree(priv);
        }
 
+       mutex_unlock(&xc2028_list_mutex);
+
        return 0;
 }
 
@@ -940,6 +946,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;
@@ -949,8 +957,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;
@@ -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");
 
+       mutex_unlock(&xc2028_list_mutex);
+
        return fe;
 }
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to