aboutsummaryrefslogtreecommitdiffstats
path: root/sound/synth/emux
diff options
context:
space:
mode:
Diffstat (limited to 'sound/synth/emux')
-rw-r--r--sound/synth/emux/emux.c8
-rw-r--r--sound/synth/emux/emux_nrpn.c8
-rw-r--r--sound/synth/emux/emux_oss.c42
-rw-r--r--sound/synth/emux/emux_seq.c15
-rw-r--r--sound/synth/emux/emux_synth.c47
5 files changed, 72 insertions, 48 deletions
diff --git a/sound/synth/emux/emux.c b/sound/synth/emux/emux.c
index c89d2ea594b9..f16a3fce4597 100644
--- a/sound/synth/emux/emux.c
+++ b/sound/synth/emux/emux.c
@@ -93,10 +93,10 @@ int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, ch
93 int err; 93 int err;
94 struct snd_sf_callback sf_cb; 94 struct snd_sf_callback sf_cb;
95 95
96 snd_assert(emu->hw != NULL, return -EINVAL); 96 if (snd_BUG_ON(!emu->hw || emu->max_voices <= 0))
97 snd_assert(emu->max_voices > 0, return -EINVAL); 97 return -EINVAL;
98 snd_assert(card != NULL, return -EINVAL); 98 if (snd_BUG_ON(!card || !name))
99 snd_assert(name != NULL, return -EINVAL); 99 return -EINVAL;
100 100
101 emu->card = card; 101 emu->card = card;
102 emu->name = kstrdup(name, GFP_KERNEL); 102 emu->name = kstrdup(name, GFP_KERNEL);
diff --git a/sound/synth/emux/emux_nrpn.c b/sound/synth/emux/emux_nrpn.c
index c6917ba2c934..00fc005ecf6e 100644
--- a/sound/synth/emux/emux_nrpn.c
+++ b/sound/synth/emux/emux_nrpn.c
@@ -289,8 +289,8 @@ snd_emux_nrpn(void *p, struct snd_midi_channel *chan,
289 struct snd_emux_port *port; 289 struct snd_emux_port *port;
290 290
291 port = p; 291 port = p;
292 snd_assert(port != NULL, return); 292 if (snd_BUG_ON(!port || !chan))
293 snd_assert(chan != NULL, return); 293 return;
294 294
295 if (chan->control[MIDI_CTL_NONREG_PARM_NUM_MSB] == 127 && 295 if (chan->control[MIDI_CTL_NONREG_PARM_NUM_MSB] == 127 &&
296 chan->control[MIDI_CTL_NONREG_PARM_NUM_LSB] <= 26) { 296 chan->control[MIDI_CTL_NONREG_PARM_NUM_LSB] <= 26) {
@@ -379,8 +379,8 @@ snd_emux_sysex(void *p, unsigned char *buf, int len, int parsed,
379 struct snd_emux *emu; 379 struct snd_emux *emu;
380 380
381 port = p; 381 port = p;
382 snd_assert(port != NULL, return); 382 if (snd_BUG_ON(!port || !chset))
383 snd_assert(chset != NULL, return); 383 return;
384 emu = port->emu; 384 emu = port->emu;
385 385
386 switch (parsed) { 386 switch (parsed) {
diff --git a/sound/synth/emux/emux_oss.c b/sound/synth/emux/emux_oss.c
index f60a98ef7dec..5c47b6c09264 100644
--- a/sound/synth/emux/emux_oss.c
+++ b/sound/synth/emux/emux_oss.c
@@ -114,7 +114,8 @@ snd_emux_open_seq_oss(struct snd_seq_oss_arg *arg, void *closure)
114 char tmpname[64]; 114 char tmpname[64];
115 115
116 emu = closure; 116 emu = closure;
117 snd_assert(arg != NULL && emu != NULL, return -ENXIO); 117 if (snd_BUG_ON(!arg || !emu))
118 return -ENXIO;
118 119
119 mutex_lock(&emu->register_mutex); 120 mutex_lock(&emu->register_mutex);
120 121
@@ -183,12 +184,15 @@ snd_emux_close_seq_oss(struct snd_seq_oss_arg *arg)
183 struct snd_emux *emu; 184 struct snd_emux *emu;
184 struct snd_emux_port *p; 185 struct snd_emux_port *p;
185 186
186 snd_assert(arg != NULL, return -ENXIO); 187 if (snd_BUG_ON(!arg))
188 return -ENXIO;
187 p = arg->private_data; 189 p = arg->private_data;
188 snd_assert(p != NULL, return -ENXIO); 190 if (snd_BUG_ON(!p))
191 return -ENXIO;
189 192
190 emu = p->emu; 193 emu = p->emu;
191 snd_assert(emu != NULL, return -ENXIO); 194 if (snd_BUG_ON(!emu))
195 return -ENXIO;
192 196
193 mutex_lock(&emu->register_mutex); 197 mutex_lock(&emu->register_mutex);
194 snd_emux_sounds_off_all(p); 198 snd_emux_sounds_off_all(p);
@@ -212,12 +216,15 @@ snd_emux_load_patch_seq_oss(struct snd_seq_oss_arg *arg, int format,
212 struct snd_emux_port *p; 216 struct snd_emux_port *p;
213 int rc; 217 int rc;
214 218
215 snd_assert(arg != NULL, return -ENXIO); 219 if (snd_BUG_ON(!arg))
220 return -ENXIO;
216 p = arg->private_data; 221 p = arg->private_data;
217 snd_assert(p != NULL, return -ENXIO); 222 if (snd_BUG_ON(!p))
223 return -ENXIO;
218 224
219 emu = p->emu; 225 emu = p->emu;
220 snd_assert(emu != NULL, return -ENXIO); 226 if (snd_BUG_ON(!emu))
227 return -ENXIO;
221 228
222 if (format == GUS_PATCH) 229 if (format == GUS_PATCH)
223 rc = snd_soundfont_load_guspatch(emu->sflist, buf, count, 230 rc = snd_soundfont_load_guspatch(emu->sflist, buf, count,
@@ -252,12 +259,15 @@ snd_emux_ioctl_seq_oss(struct snd_seq_oss_arg *arg, unsigned int cmd, unsigned l
252 struct snd_emux_port *p; 259 struct snd_emux_port *p;
253 struct snd_emux *emu; 260 struct snd_emux *emu;
254 261
255 snd_assert(arg != NULL, return -ENXIO); 262 if (snd_BUG_ON(!arg))
263 return -ENXIO;
256 p = arg->private_data; 264 p = arg->private_data;
257 snd_assert(p != NULL, return -ENXIO); 265 if (snd_BUG_ON(!p))
266 return -ENXIO;
258 267
259 emu = p->emu; 268 emu = p->emu;
260 snd_assert(emu != NULL, return -ENXIO); 269 if (snd_BUG_ON(!emu))
270 return -ENXIO;
261 271
262 switch (cmd) { 272 switch (cmd) {
263 case SNDCTL_SEQ_RESETSAMPLES: 273 case SNDCTL_SEQ_RESETSAMPLES:
@@ -282,9 +292,11 @@ snd_emux_reset_seq_oss(struct snd_seq_oss_arg *arg)
282{ 292{
283 struct snd_emux_port *p; 293 struct snd_emux_port *p;
284 294
285 snd_assert(arg != NULL, return -ENXIO); 295 if (snd_BUG_ON(!arg))
296 return -ENXIO;
286 p = arg->private_data; 297 p = arg->private_data;
287 snd_assert(p != NULL, return -ENXIO); 298 if (snd_BUG_ON(!p))
299 return -ENXIO;
288 snd_emux_reset_port(p); 300 snd_emux_reset_port(p);
289 return 0; 301 return 0;
290} 302}
@@ -302,9 +314,11 @@ snd_emux_event_oss_input(struct snd_seq_event *ev, int direct, void *private_dat
302 unsigned char cmd, *data; 314 unsigned char cmd, *data;
303 315
304 p = private_data; 316 p = private_data;
305 snd_assert(p != NULL, return -EINVAL); 317 if (snd_BUG_ON(!p))
318 return -EINVAL;
306 emu = p->emu; 319 emu = p->emu;
307 snd_assert(emu != NULL, return -EINVAL); 320 if (snd_BUG_ON(!emu))
321 return -EINVAL;
308 if (ev->type != SNDRV_SEQ_EVENT_OSS) 322 if (ev->type != SNDRV_SEQ_EVENT_OSS)
309 return snd_emux_event_input(ev, direct, private_data, atomic, hop); 323 return snd_emux_event_input(ev, direct, private_data, atomic, hop);
310 324
diff --git a/sound/synth/emux/emux_seq.c b/sound/synth/emux/emux_seq.c
index d176cc01742d..335aa2ce2574 100644
--- a/sound/synth/emux/emux_seq.c
+++ b/sound/synth/emux/emux_seq.c
@@ -257,7 +257,8 @@ snd_emux_event_input(struct snd_seq_event *ev, int direct, void *private_data,
257 struct snd_emux_port *port; 257 struct snd_emux_port *port;
258 258
259 port = private_data; 259 port = private_data;
260 snd_assert(port != NULL && ev != NULL, return -EINVAL); 260 if (snd_BUG_ON(!port || !ev))
261 return -EINVAL;
261 262
262 snd_midi_process_event(&emux_ops, ev, &port->chset); 263 snd_midi_process_event(&emux_ops, ev, &port->chset);
263 264
@@ -308,9 +309,11 @@ snd_emux_use(void *private_data, struct snd_seq_port_subscribe *info)
308 struct snd_emux *emu; 309 struct snd_emux *emu;
309 310
310 p = private_data; 311 p = private_data;
311 snd_assert(p != NULL, return -EINVAL); 312 if (snd_BUG_ON(!p))
313 return -EINVAL;
312 emu = p->emu; 314 emu = p->emu;
313 snd_assert(emu != NULL, return -EINVAL); 315 if (snd_BUG_ON(!emu))
316 return -EINVAL;
314 317
315 mutex_lock(&emu->register_mutex); 318 mutex_lock(&emu->register_mutex);
316 snd_emux_init_port(p); 319 snd_emux_init_port(p);
@@ -329,9 +332,11 @@ snd_emux_unuse(void *private_data, struct snd_seq_port_subscribe *info)
329 struct snd_emux *emu; 332 struct snd_emux *emu;
330 333
331 p = private_data; 334 p = private_data;
332 snd_assert(p != NULL, return -EINVAL); 335 if (snd_BUG_ON(!p))
336 return -EINVAL;
333 emu = p->emu; 337 emu = p->emu;
334 snd_assert(emu != NULL, return -EINVAL); 338 if (snd_BUG_ON(!emu))
339 return -EINVAL;
335 340
336 mutex_lock(&emu->register_mutex); 341 mutex_lock(&emu->register_mutex);
337 snd_emux_sounds_off_all(p); 342 snd_emux_sounds_off_all(p);
diff --git a/sound/synth/emux/emux_synth.c b/sound/synth/emux/emux_synth.c
index b343818dbb96..2cc6f6f79065 100644
--- a/sound/synth/emux/emux_synth.c
+++ b/sound/synth/emux/emux_synth.c
@@ -66,12 +66,12 @@ snd_emux_note_on(void *p, int note, int vel, struct snd_midi_channel *chan)
66 struct snd_emux_port *port; 66 struct snd_emux_port *port;
67 67
68 port = p; 68 port = p;
69 snd_assert(port != NULL && chan != NULL, return); 69 if (snd_BUG_ON(!port || !chan))
70 return;
70 71
71 emu = port->emu; 72 emu = port->emu;
72 snd_assert(emu != NULL, return); 73 if (snd_BUG_ON(!emu || !emu->ops.get_voice || !emu->ops.trigger))
73 snd_assert(emu->ops.get_voice != NULL, return); 74 return;
74 snd_assert(emu->ops.trigger != NULL, return);
75 75
76 key = note; /* remember the original note */ 76 key = note; /* remember the original note */
77 nvoices = get_zone(emu, port, &note, vel, chan, table); 77 nvoices = get_zone(emu, port, &note, vel, chan, table);
@@ -164,11 +164,12 @@ snd_emux_note_off(void *p, int note, int vel, struct snd_midi_channel *chan)
164 struct snd_emux_port *port; 164 struct snd_emux_port *port;
165 165
166 port = p; 166 port = p;
167 snd_assert(port != NULL && chan != NULL, return); 167 if (snd_BUG_ON(!port || !chan))
168 return;
168 169
169 emu = port->emu; 170 emu = port->emu;
170 snd_assert(emu != NULL, return); 171 if (snd_BUG_ON(!emu || !emu->ops.release))
171 snd_assert(emu->ops.release != NULL, return); 172 return;
172 173
173 spin_lock_irqsave(&emu->voice_lock, flags); 174 spin_lock_irqsave(&emu->voice_lock, flags);
174 for (ch = 0; ch < emu->max_voices; ch++) { 175 for (ch = 0; ch < emu->max_voices; ch++) {
@@ -242,11 +243,12 @@ snd_emux_key_press(void *p, int note, int vel, struct snd_midi_channel *chan)
242 struct snd_emux_port *port; 243 struct snd_emux_port *port;
243 244
244 port = p; 245 port = p;
245 snd_assert(port != NULL && chan != NULL, return); 246 if (snd_BUG_ON(!port || !chan))
247 return;
246 248
247 emu = port->emu; 249 emu = port->emu;
248 snd_assert(emu != NULL, return); 250 if (snd_BUG_ON(!emu || !emu->ops.update))
249 snd_assert(emu->ops.update != NULL, return); 251 return;
250 252
251 spin_lock_irqsave(&emu->voice_lock, flags); 253 spin_lock_irqsave(&emu->voice_lock, flags);
252 for (ch = 0; ch < emu->max_voices; ch++) { 254 for (ch = 0; ch < emu->max_voices; ch++) {
@@ -276,8 +278,8 @@ snd_emux_update_channel(struct snd_emux_port *port, struct snd_midi_channel *cha
276 return; 278 return;
277 279
278 emu = port->emu; 280 emu = port->emu;
279 snd_assert(emu != NULL, return); 281 if (snd_BUG_ON(!emu || !emu->ops.update))
280 snd_assert(emu->ops.update != NULL, return); 282 return;
281 283
282 spin_lock_irqsave(&emu->voice_lock, flags); 284 spin_lock_irqsave(&emu->voice_lock, flags);
283 for (i = 0; i < emu->max_voices; i++) { 285 for (i = 0; i < emu->max_voices; i++) {
@@ -303,8 +305,8 @@ snd_emux_update_port(struct snd_emux_port *port, int update)
303 return; 305 return;
304 306
305 emu = port->emu; 307 emu = port->emu;
306 snd_assert(emu != NULL, return); 308 if (snd_BUG_ON(!emu || !emu->ops.update))
307 snd_assert(emu->ops.update != NULL, return); 309 return;
308 310
309 spin_lock_irqsave(&emu->voice_lock, flags); 311 spin_lock_irqsave(&emu->voice_lock, flags);
310 for (i = 0; i < emu->max_voices; i++) { 312 for (i = 0; i < emu->max_voices; i++) {
@@ -326,7 +328,8 @@ snd_emux_control(void *p, int type, struct snd_midi_channel *chan)
326 struct snd_emux_port *port; 328 struct snd_emux_port *port;
327 329
328 port = p; 330 port = p;
329 snd_assert(port != NULL && chan != NULL, return); 331 if (snd_BUG_ON(!port || !chan))
332 return;
330 333
331 switch (type) { 334 switch (type) {
332 case MIDI_CTL_MSB_MAIN_VOLUME: 335 case MIDI_CTL_MSB_MAIN_VOLUME:
@@ -400,11 +403,12 @@ snd_emux_terminate_note(void *p, int note, struct snd_midi_channel *chan)
400 struct snd_emux_port *port; 403 struct snd_emux_port *port;
401 404
402 port = p; 405 port = p;
403 snd_assert(port != NULL && chan != NULL, return); 406 if (snd_BUG_ON(!port || !chan))
407 return;
404 408
405 emu = port->emu; 409 emu = port->emu;
406 snd_assert(emu != NULL, return); 410 if (snd_BUG_ON(!emu || !emu->ops.terminate))
407 snd_assert(emu->ops.terminate != NULL, return); 411 return;
408 412
409 terminate_note1(emu, note, chan, 1); 413 terminate_note1(emu, note, chan, 1);
410} 414}
@@ -451,10 +455,11 @@ snd_emux_sounds_off_all(struct snd_emux_port *port)
451 struct snd_emux_voice *vp; 455 struct snd_emux_voice *vp;
452 unsigned long flags; 456 unsigned long flags;
453 457
454 snd_assert(port != NULL, return); 458 if (snd_BUG_ON(!port))
459 return;
455 emu = port->emu; 460 emu = port->emu;
456 snd_assert(emu != NULL, return); 461 if (snd_BUG_ON(!emu || !emu->ops.terminate))
457 snd_assert(emu->ops.terminate != NULL, return); 462 return;
458 463
459 spin_lock_irqsave(&emu->voice_lock, flags); 464 spin_lock_irqsave(&emu->voice_lock, flags);
460 for (i = 0; i < emu->max_voices; i++) { 465 for (i = 0; i < emu->max_voices; i++) {