diff options
author | Takashi Iwai <tiwai@suse.de> | 2010-04-07 07:54:33 (GMT) |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2010-04-07 07:54:33 (GMT) |
commit | 1172234cbe94658c16bc83e50ca57b5a47085209 (patch) | |
tree | 15bddd783be48899167a9cd764d3f23cfd05572e /sound/pci/mixart/mixart.c | |
parent | 85255c0e078158ede61ff8bd296e306db6f7ed19 (diff) | |
parent | b0cc58a25d04160d39a80e436847eaa2fbc5aa09 (diff) | |
download | linux-1172234cbe94658c16bc83e50ca57b5a47085209.tar.xz |
Merge branch 'fix/misc' into for-linus
Diffstat (limited to 'sound/pci/mixart/mixart.c')
-rw-r--r-- | sound/pci/mixart/mixart.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c index 7e8e7da..ea4256b 100644 --- a/sound/pci/mixart/mixart.c +++ b/sound/pci/mixart/mixart.c @@ -1161,13 +1161,15 @@ static long snd_mixart_BA0_read(struct snd_info_entry *entry, void *file_private unsigned long count, unsigned long pos) { struct mixart_mgr *mgr = entry->private_data; + unsigned long maxsize; - count = count & ~3; /* make sure the read size is a multiple of 4 bytes */ - if(count <= 0) + if (pos >= MIXART_BA0_SIZE) return 0; - if(pos + count > MIXART_BA0_SIZE) - count = (long)(MIXART_BA0_SIZE - pos); - if(copy_to_user_fromio(buf, MIXART_MEM( mgr, pos ), count)) + maxsize = MIXART_BA0_SIZE - pos; + if (count > maxsize) + count = maxsize; + count = count & ~3; /* make sure the read size is a multiple of 4 bytes */ + if (copy_to_user_fromio(buf, MIXART_MEM(mgr, pos), count)) return -EFAULT; return count; } @@ -1180,13 +1182,15 @@ static long snd_mixart_BA1_read(struct snd_info_entry *entry, void *file_private unsigned long count, unsigned long pos) { struct mixart_mgr *mgr = entry->private_data; + unsigned long maxsize; - count = count & ~3; /* make sure the read size is a multiple of 4 bytes */ - if(count <= 0) + if (pos > MIXART_BA1_SIZE) return 0; - if(pos + count > MIXART_BA1_SIZE) - count = (long)(MIXART_BA1_SIZE - pos); - if(copy_to_user_fromio(buf, MIXART_REG( mgr, pos ), count)) + maxsize = MIXART_BA1_SIZE - pos; + if (count > maxsize) + count = maxsize; + count = count & ~3; /* make sure the read size is a multiple of 4 bytes */ + if (copy_to_user_fromio(buf, MIXART_REG(mgr, pos), count)) return -EFAULT; return count; } |