summaryrefslogtreecommitdiff
path: root/sound/pci/emu10k1/emu10k1_patch.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/emu10k1/emu10k1_patch.c')
-rw-r--r--sound/pci/emu10k1/emu10k1_patch.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/sound/pci/emu10k1/emu10k1_patch.c b/sound/pci/emu10k1/emu10k1_patch.c
index 42bae6f7e9a4..e10f027bde03 100644
--- a/sound/pci/emu10k1/emu10k1_patch.c
+++ b/sound/pci/emu10k1/emu10k1_patch.c
@@ -46,8 +46,8 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
struct snd_emu10k1 *emu;
emu = rec->hw;
- snd_assert(sp != NULL, return -EINVAL);
- snd_assert(hdr != NULL, return -EINVAL);
+ if (snd_BUG_ON(!sp || !hdr))
+ return -EINVAL;
if (sp->v.size == 0) {
snd_printd("emu: rom font for sample %d\n", sp->v.sample);
@@ -104,7 +104,8 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
size = BLANK_HEAD_SIZE;
if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS))
size *= 2;
- snd_assert(offset + size <= blocksize, return -EINVAL);
+ if (offset + size > blocksize)
+ return -EINVAL;
snd_emu10k1_synth_bzero(emu, sp->block, offset, size);
offset += size;
@@ -112,7 +113,8 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
size = loopend;
if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS))
size *= 2;
- snd_assert(offset + size <= blocksize, return -EINVAL);
+ if (offset + size > blocksize)
+ return -EINVAL;
if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size)) {
snd_emu10k1_synth_free(emu, sp->block);
sp->block = NULL;
@@ -129,12 +131,14 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
int woffset;
unsigned short *wblock = (unsigned short*)block;
woffset = offset / 2;
- snd_assert(offset + loopsize*2 <= blocksize, return -EINVAL);
+ if (offset + loopsize * 2 > blocksize)
+ return -EINVAL;
for (i = 0; i < loopsize; i++)
wblock[woffset + i] = wblock[woffset - i -1];
offset += loopsize * 2;
} else {
- snd_assert(offset + loopsize <= blocksize, return -EINVAL);
+ if (offset + loopsize > blocksize)
+ return -EINVAL;
for (i = 0; i < loopsize; i++)
block[offset + i] = block[offset - i -1];
offset += loopsize;
@@ -154,7 +158,8 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,
/* loopend -> sample end */
size = sp->v.size - loopend;
- snd_assert(size >= 0, return -EINVAL);
+ if (size < 0)
+ return -EINVAL;
if (! (sp->v.mode_flags & SNDRV_SFNT_SAMPLE_8BITS))
size *= 2;
if (snd_emu10k1_synth_copy_from_user(emu, sp->block, offset, data, size)) {
@@ -212,8 +217,8 @@ snd_emu10k1_sample_free(struct snd_emux *rec, struct snd_sf_sample *sp,
struct snd_emu10k1 *emu;
emu = rec->hw;
- snd_assert(sp != NULL, return -EINVAL);
- snd_assert(hdr != NULL, return -EINVAL);
+ if (snd_BUG_ON(!sp || !hdr))
+ return -EINVAL;
if (sp->block) {
snd_emu10k1_synth_free(emu, sp->block);