Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 22773
b: refs/heads/master
c: 6464940
h: refs/heads/master
i:
  22771: f11e657
v: v3
  • Loading branch information
Giuliano Pochini authored and Jaroslav Kysela committed Mar 22, 2006
1 parent 30cc55f commit 0913802
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9230d2148a0c53188c216b446cf17ea213ebca8a
refs/heads/master: 646494007b48e8897888cd407c2b7d1d69cb2e58
20 changes: 17 additions & 3 deletions trunk/sound/core/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,11 @@ static int snd_ctl_elem_info_user(struct snd_ctl_file *ctl,

if (copy_from_user(&info, _info, sizeof(info)))
return -EFAULT;
result = snd_ctl_elem_info(ctl, &info);
snd_power_lock(ctl->card);
result = snd_power_wait(ctl->card, SNDRV_CTL_POWER_D0, NULL);
if (result >= 0)
result = snd_ctl_elem_info(ctl, &info);
snd_power_unlock(ctl->card);
if (result >= 0)
if (copy_to_user(_info, &info, sizeof(info)))
return -EFAULT;
Expand Down Expand Up @@ -708,7 +712,11 @@ static int snd_ctl_elem_read_user(struct snd_card *card,
kfree(control);
return -EFAULT;
}
result = snd_ctl_elem_read(card, control);
snd_power_lock(card);
result = snd_power_wait(card, SNDRV_CTL_POWER_D0, NULL);
if (result >= 0)
result = snd_ctl_elem_read(card, control);
snd_power_unlock(card);
if (result >= 0)
if (copy_to_user(_control, control, sizeof(*control)))
result = -EFAULT;
Expand Down Expand Up @@ -758,6 +766,7 @@ static int snd_ctl_elem_write_user(struct snd_ctl_file *file,
struct snd_ctl_elem_value __user *_control)
{
struct snd_ctl_elem_value *control;
struct snd_card *card;
int result;

control = kmalloc(sizeof(*control), GFP_KERNEL);
Expand All @@ -767,7 +776,12 @@ static int snd_ctl_elem_write_user(struct snd_ctl_file *file,
kfree(control);
return -EFAULT;
}
result = snd_ctl_elem_write(file->card, file, control);
card = file->card;
snd_power_lock(card);
result = snd_power_wait(card, SNDRV_CTL_POWER_D0, NULL);
if (result >= 0)
result = snd_ctl_elem_write(card, file, control);
snd_power_unlock(card);
if (result >= 0)
if (copy_to_user(_control, control, sizeof(*control)))
result = -EFAULT;
Expand Down
33 changes: 25 additions & 8 deletions trunk/sound/core/control_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,13 @@ static int snd_ctl_elem_info_compat(struct snd_ctl_file *ctl,
*/
if (get_user(data->value.enumerated.item, &data32->value.enumerated.item))
goto error;
err = snd_ctl_elem_info(ctl, data);

snd_power_lock(ctl->card);
err = snd_power_wait(ctl->card, SNDRV_CTL_POWER_D0, NULL);
if (err >= 0)
err = snd_ctl_elem_info(ctl, data);
snd_power_unlock(ctl->card);

if (err < 0)
goto error;
/* restore info to 32bit */
Expand Down Expand Up @@ -286,9 +292,14 @@ static int snd_ctl_elem_read_user_compat(struct snd_card *card,

if ((err = copy_ctl_value_from_user(card, data, data32, &type, &count)) < 0)
goto error;
if ((err = snd_ctl_elem_read(card, data)) < 0)
goto error;
err = copy_ctl_value_to_user(data32, data, type, count);

snd_power_lock(card);
err = snd_power_wait(card, SNDRV_CTL_POWER_D0, NULL);
if (err >= 0)
err = snd_ctl_elem_read(card, data);
snd_power_unlock(card);
if (err >= 0)
err = copy_ctl_value_to_user(data32, data, type, count);
error:
kfree(data);
return err;
Expand All @@ -298,17 +309,23 @@ static int snd_ctl_elem_write_user_compat(struct snd_ctl_file *file,
struct snd_ctl_elem_value32 __user *data32)
{
struct snd_ctl_elem_value *data;
struct snd_card *card = file->card;
int err, type, count;

data = kzalloc(sizeof(*data), GFP_KERNEL);
if (data == NULL)
return -ENOMEM;

if ((err = copy_ctl_value_from_user(file->card, data, data32, &type, &count)) < 0)
goto error;
if ((err = snd_ctl_elem_write(file->card, file, data)) < 0)
if ((err = copy_ctl_value_from_user(card, data, data32, &type, &count)) < 0)
goto error;
err = copy_ctl_value_to_user(data32, data, type, count);

snd_power_lock(card);
err = snd_power_wait(card, SNDRV_CTL_POWER_D0, NULL);
if (err >= 0)
err = snd_ctl_elem_write(card, file, data);
snd_power_unlock(card);
if (err >= 0)
err = copy_ctl_value_to_user(data32, data, type, count);
error:
kfree(data);
return err;
Expand Down

0 comments on commit 0913802

Please sign in to comment.