aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/seq/oss/seq_oss_init.c40
-rw-r--r--sound/core/seq/oss/seq_oss_writeq.c6
2 files changed, 27 insertions, 19 deletions
diff --git a/sound/core/seq/oss/seq_oss_init.c b/sound/core/seq/oss/seq_oss_init.c
index ca5a2ed4d7c3..d0d721c22eac 100644
--- a/sound/core/seq/oss/seq_oss_init.c
+++ b/sound/core/seq/oss/seq_oss_init.c
@@ -176,29 +176,29 @@ snd_seq_oss_open(struct file *file, int level)
176 int i, rc; 176 int i, rc;
177 struct seq_oss_devinfo *dp; 177 struct seq_oss_devinfo *dp;
178 178
179 if ((dp = kzalloc(sizeof(*dp), GFP_KERNEL)) == NULL) { 179 dp = kzalloc(sizeof(*dp), GFP_KERNEL);
180 if (!dp) {
180 snd_printk(KERN_ERR "can't malloc device info\n"); 181 snd_printk(KERN_ERR "can't malloc device info\n");
181 return -ENOMEM; 182 return -ENOMEM;
182 } 183 }
183 debug_printk(("oss_open: dp = %p\n", dp)); 184 debug_printk(("oss_open: dp = %p\n", dp));
184 185
186 dp->cseq = system_client;
187 dp->port = -1;
188 dp->queue = -1;
189
185 for (i = 0; i < SNDRV_SEQ_OSS_MAX_CLIENTS; i++) { 190 for (i = 0; i < SNDRV_SEQ_OSS_MAX_CLIENTS; i++) {
186 if (client_table[i] == NULL) 191 if (client_table[i] == NULL)
187 break; 192 break;
188 } 193 }
194
195 dp->index = i;
189 if (i >= SNDRV_SEQ_OSS_MAX_CLIENTS) { 196 if (i >= SNDRV_SEQ_OSS_MAX_CLIENTS) {
190 snd_printk(KERN_ERR "too many applications\n"); 197 snd_printk(KERN_ERR "too many applications\n");
191 kfree(dp); 198 rc = -ENOMEM;
192 return -ENOMEM; 199 goto _error;
193 } 200 }
194 201
195 dp->index = i;
196 dp->cseq = system_client;
197 dp->port = -1;
198 dp->queue = -1;
199 dp->readq = NULL;
200 dp->writeq = NULL;
201
202 /* look up synth and midi devices */ 202 /* look up synth and midi devices */
203 snd_seq_oss_synth_setup(dp); 203 snd_seq_oss_synth_setup(dp);
204 snd_seq_oss_midi_setup(dp); 204 snd_seq_oss_midi_setup(dp);
@@ -211,14 +211,16 @@ snd_seq_oss_open(struct file *file, int level)
211 211
212 /* create port */ 212 /* create port */
213 debug_printk(("create new port\n")); 213 debug_printk(("create new port\n"));
214 if ((rc = create_port(dp)) < 0) { 214 rc = create_port(dp);
215 if (rc < 0) {
215 snd_printk(KERN_ERR "can't create port\n"); 216 snd_printk(KERN_ERR "can't create port\n");
216 goto _error; 217 goto _error;
217 } 218 }
218 219
219 /* allocate queue */ 220 /* allocate queue */
220 debug_printk(("allocate queue\n")); 221 debug_printk(("allocate queue\n"));
221 if ((rc = alloc_seq_queue(dp)) < 0) 222 rc = alloc_seq_queue(dp);
223 if (rc < 0)
222 goto _error; 224 goto _error;
223 225
224 /* set address */ 226 /* set address */
@@ -235,7 +237,8 @@ snd_seq_oss_open(struct file *file, int level)
235 /* initialize read queue */ 237 /* initialize read queue */
236 debug_printk(("initialize read queue\n")); 238 debug_printk(("initialize read queue\n"));
237 if (is_read_mode(dp->file_mode)) { 239 if (is_read_mode(dp->file_mode)) {
238 if ((dp->readq = snd_seq_oss_readq_new(dp, maxqlen)) == NULL) { 240 dp->readq = snd_seq_oss_readq_new(dp, maxqlen);
241 if (!dp->readq) {
239 rc = -ENOMEM; 242 rc = -ENOMEM;
240 goto _error; 243 goto _error;
241 } 244 }
@@ -245,7 +248,7 @@ snd_seq_oss_open(struct file *file, int level)
245 debug_printk(("initialize write queue\n")); 248 debug_printk(("initialize write queue\n"));
246 if (is_write_mode(dp->file_mode)) { 249 if (is_write_mode(dp->file_mode)) {
247 dp->writeq = snd_seq_oss_writeq_new(dp, maxqlen); 250 dp->writeq = snd_seq_oss_writeq_new(dp, maxqlen);
248 if (dp->writeq == NULL) { 251 if (!dp->writeq) {
249 rc = -ENOMEM; 252 rc = -ENOMEM;
250 goto _error; 253 goto _error;
251 } 254 }
@@ -253,7 +256,8 @@ snd_seq_oss_open(struct file *file, int level)
253 256
254 /* initialize timer */ 257 /* initialize timer */
255 debug_printk(("initialize timer\n")); 258 debug_printk(("initialize timer\n"));
256 if ((dp->timer = snd_seq_oss_timer_new(dp)) == NULL) { 259 dp->timer = snd_seq_oss_timer_new(dp);
260 if (!dp->timer) {
257 snd_printk(KERN_ERR "can't alloc timer\n"); 261 snd_printk(KERN_ERR "can't alloc timer\n");
258 rc = -ENOMEM; 262 rc = -ENOMEM;
259 goto _error; 263 goto _error;
@@ -276,11 +280,13 @@ snd_seq_oss_open(struct file *file, int level)
276 return 0; 280 return 0;
277 281
278 _error: 282 _error:
283 snd_seq_oss_writeq_delete(dp->writeq);
284 snd_seq_oss_readq_delete(dp->readq);
279 snd_seq_oss_synth_cleanup(dp); 285 snd_seq_oss_synth_cleanup(dp);
280 snd_seq_oss_midi_cleanup(dp); 286 snd_seq_oss_midi_cleanup(dp);
281 i = dp->queue;
282 delete_port(dp); 287 delete_port(dp);
283 delete_seq_queue(i); 288 delete_seq_queue(dp->queue);
289 kfree(dp);
284 290
285 return rc; 291 return rc;
286} 292}
diff --git a/sound/core/seq/oss/seq_oss_writeq.c b/sound/core/seq/oss/seq_oss_writeq.c
index 5c8495601a38..217424858191 100644
--- a/sound/core/seq/oss/seq_oss_writeq.c
+++ b/sound/core/seq/oss/seq_oss_writeq.c
@@ -63,8 +63,10 @@ snd_seq_oss_writeq_new(struct seq_oss_devinfo *dp, int maxlen)
63void 63void
64snd_seq_oss_writeq_delete(struct seq_oss_writeq *q) 64snd_seq_oss_writeq_delete(struct seq_oss_writeq *q)
65{ 65{
66 snd_seq_oss_writeq_clear(q); /* to be sure */ 66 if (q) {
67 kfree(q); 67 snd_seq_oss_writeq_clear(q); /* to be sure */
68 kfree(q);
69 }
68} 70}
69 71
70 72