summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew de Quincey <adq_dvb@lidskialf.net>2006-04-04 13:41:47 +0100
committerAndrew de Quincey <adq_dvb@lidskialf.net>2006-04-04 13:41:47 +0100
commit90f7453adee2bcad39c6630b760358eb799f238d (patch)
tree928c8d75b4776e73ca65dd11028f2e9526d1c7d3
parentd8eae1def78bd2a6dfa017145311a249c7aa3bc6 (diff)
downloadmediapointer-dvb-s2-90f7453adee2bcad39c6630b760358eb799f238d.tar.gz
mediapointer-dvb-s2-90f7453adee2bcad39c6630b760358eb799f238d.tar.bz2
Fix mutex in dvb_register_device to work.
From: Andrew de Quincey <adq_dvb@lidskialf.net> This mutex is meant to stop two devices getting the same ID. dvbdev_get_free_id() scans the list of already allocated devices to find a free id. Unfortunately, since the mutex is unlocked before the card is added to the above list, it is still possible for two of them to get the same id. Solution: move the mutex after the list_add. Its debatable whether this mutex lock is actually needed, but I'm unwilling to just remove it in case something does depend on it. Signed-off-by: Andrew de Quincey <adq_dvb@lidskialf.net>
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvbdev.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/linux/drivers/media/dvb/dvb-core/dvbdev.c b/linux/drivers/media/dvb/dvb-core/dvbdev.c
index 9b824c31b..041ed7fd1 100644
--- a/linux/drivers/media/dvb/dvb-core/dvbdev.c
+++ b/linux/drivers/media/dvb/dvb-core/dvbdev.c
@@ -230,8 +230,6 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
return -ENOMEM;
}
- mutex_unlock(&dvbdev_register_lock);
-
memcpy(dvbdev, template, sizeof(struct dvb_device));
dvbdev->type = type;
dvbdev->id = id;
@@ -242,6 +240,8 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
list_add_tail (&dvbdev->list_head, &adap->device_list);
+ mutex_unlock(&dvbdev_register_lock);
+
devfs_mk_cdev(MKDEV(DVB_MAJOR, nums2minor(adap->num, type, id)),
S_IFCHR | S_IRUSR | S_IWUSR,
"dvb/adapter%d/%s%d", adap->num, dnames[type], id);