summaryrefslogtreecommitdiffstats
path: root/sound/core/control.c
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2009-11-02 09:35:44 +0100
committerTakashi Iwai <tiwai@suse.de>2009-11-06 14:32:06 +0100
commit25d27eded1f4fc728e64f443adc339b5229be5d7 (patch)
treeb738266467fc0f85d9f7f29e439dfff8e33da4c0 /sound/core/control.c
parent31cef7076ed9409a33f19ea372d6dc5fdefe27ae (diff)
downloadop-kernel-dev-25d27eded1f4fc728e64f443adc339b5229be5d7.zip
op-kernel-dev-25d27eded1f4fc728e64f443adc339b5229be5d7.tar.gz
control: use reference-counted pid
Instead of storing the PID number, take a reference to the task's pid structure. This protects against duplicates due to PID overflows, and using pid_vnr() ensures that the PID returned by snd_ctl_elem_info() is correct as seen from the current namespace. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/control.c')
-rw-r--r--sound/core/control.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sound/core/control.c b/sound/core/control.c
index 814d2cf..73dc10a 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -75,7 +75,7 @@ static int snd_ctl_open(struct inode *inode, struct file *file)
ctl->card = card;
ctl->prefer_pcm_subdevice = -1;
ctl->prefer_rawmidi_subdevice = -1;
- ctl->pid = current->pid;
+ ctl->pid = get_pid(task_pid(current));
file->private_data = ctl;
write_lock_irqsave(&card->ctl_files_rwlock, flags);
list_add_tail(&ctl->list, &card->ctl_files);
@@ -125,6 +125,7 @@ static int snd_ctl_release(struct inode *inode, struct file *file)
control->vd[idx].owner = NULL;
up_write(&card->controls_rwsem);
snd_ctl_empty_read_queue(ctl);
+ put_pid(ctl->pid);
kfree(ctl);
module_put(card->module);
snd_card_file_remove(card, file);
@@ -672,7 +673,7 @@ static int snd_ctl_elem_info(struct snd_ctl_file *ctl,
info->access |= SNDRV_CTL_ELEM_ACCESS_LOCK;
if (vd->owner == ctl)
info->access |= SNDRV_CTL_ELEM_ACCESS_OWNER;
- info->owner = vd->owner->pid;
+ info->owner = pid_vnr(vd->owner->pid);
} else {
info->owner = -1;
}
OpenPOWER on IntegriCloud