aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/oss/pcm_oss.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core/oss/pcm_oss.c')
-rw-r--r--sound/core/oss/pcm_oss.c52
1 files changed, 35 insertions, 17 deletions
diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
index 4c601b192ddf..1af62b8b86c6 100644
--- a/sound/core/oss/pcm_oss.c
+++ b/sound/core/oss/pcm_oss.c
@@ -452,7 +452,8 @@ static int snd_pcm_hw_param_near(struct snd_pcm_substream *pcm,
452 } else { 452 } else {
453 *params = *save; 453 *params = *save;
454 max = snd_pcm_hw_param_max(pcm, params, var, max, &maxdir); 454 max = snd_pcm_hw_param_max(pcm, params, var, max, &maxdir);
455 snd_assert(max >= 0, return -EINVAL); 455 if (max < 0)
456 return max;
456 last = 1; 457 last = 1;
457 } 458 }
458 _end: 459 _end:
@@ -461,7 +462,7 @@ static int snd_pcm_hw_param_near(struct snd_pcm_substream *pcm,
461 v = snd_pcm_hw_param_last(pcm, params, var, dir); 462 v = snd_pcm_hw_param_last(pcm, params, var, dir);
462 else 463 else
463 v = snd_pcm_hw_param_first(pcm, params, var, dir); 464 v = snd_pcm_hw_param_first(pcm, params, var, dir);
464 snd_assert(v >= 0, return -EINVAL); 465 snd_BUG_ON(v < 0);
465 return v; 466 return v;
466} 467}
467 468
@@ -778,7 +779,8 @@ static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream,
778 while (oss_period_size * oss_periods > oss_buffer_size) 779 while (oss_period_size * oss_periods > oss_buffer_size)
779 oss_period_size /= 2; 780 oss_period_size /= 2;
780 781
781 snd_assert(oss_period_size >= 16, return -EINVAL); 782 if (oss_period_size < 16)
783 return -EINVAL;
782 runtime->oss.period_bytes = oss_period_size; 784 runtime->oss.period_bytes = oss_period_size;
783 runtime->oss.period_frames = 1; 785 runtime->oss.period_frames = 1;
784 runtime->oss.periods = oss_periods; 786 runtime->oss.periods = oss_periods;
@@ -895,7 +897,8 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
895 } 897 }
896 } 898 }
897 err = _snd_pcm_hw_param_set(sparams, SNDRV_PCM_HW_PARAM_FORMAT, sformat, 0); 899 err = _snd_pcm_hw_param_set(sparams, SNDRV_PCM_HW_PARAM_FORMAT, sformat, 0);
898 snd_assert(err >= 0, goto failure); 900 if (err < 0)
901 goto failure;
899 902
900 if (direct) { 903 if (direct) {
901 memcpy(params, sparams, sizeof(*params)); 904 memcpy(params, sparams, sizeof(*params));
@@ -958,11 +961,13 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
958 961
959 n = snd_pcm_plug_slave_size(substream, runtime->oss.period_bytes / oss_frame_size); 962 n = snd_pcm_plug_slave_size(substream, runtime->oss.period_bytes / oss_frame_size);
960 err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, n, NULL); 963 err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, n, NULL);
961 snd_assert(err >= 0, goto failure); 964 if (err < 0)
965 goto failure;
962 966
963 err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIODS, 967 err = snd_pcm_hw_param_near(substream, sparams, SNDRV_PCM_HW_PARAM_PERIODS,
964 runtime->oss.periods, NULL); 968 runtime->oss.periods, NULL);
965 snd_assert(err >= 0, goto failure); 969 if (err < 0)
970 goto failure;
966 971
967 snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL); 972 snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DROP, NULL);
968 973
@@ -1006,7 +1011,10 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
1006 1011
1007 runtime->oss.periods = params_periods(sparams); 1012 runtime->oss.periods = params_periods(sparams);
1008 oss_period_size = snd_pcm_plug_client_size(substream, params_period_size(sparams)); 1013 oss_period_size = snd_pcm_plug_client_size(substream, params_period_size(sparams));
1009 snd_assert(oss_period_size >= 0, err = -EINVAL; goto failure); 1014 if (oss_period_size < 0) {
1015 err = -EINVAL;
1016 goto failure;
1017 }
1010#ifdef CONFIG_SND_PCM_OSS_PLUGINS 1018#ifdef CONFIG_SND_PCM_OSS_PLUGINS
1011 if (runtime->oss.plugin_first) { 1019 if (runtime->oss.plugin_first) {
1012 err = snd_pcm_plug_alloc(substream, oss_period_size); 1020 err = snd_pcm_plug_alloc(substream, oss_period_size);
@@ -1017,7 +1025,10 @@ static int snd_pcm_oss_change_params(struct snd_pcm_substream *substream)
1017 oss_period_size *= oss_frame_size; 1025 oss_period_size *= oss_frame_size;
1018 1026
1019 oss_buffer_size = oss_period_size * runtime->oss.periods; 1027 oss_buffer_size = oss_period_size * runtime->oss.periods;
1020 snd_assert(oss_buffer_size >= 0, err = -EINVAL; goto failure); 1028 if (oss_buffer_size < 0) {
1029 err = -EINVAL;
1030 goto failure;
1031 }
1021 1032
1022 runtime->oss.period_bytes = oss_period_size; 1033 runtime->oss.period_bytes = oss_period_size;
1023 runtime->oss.buffer_bytes = oss_buffer_size; 1034 runtime->oss.buffer_bytes = oss_buffer_size;
@@ -1069,7 +1080,8 @@ static int snd_pcm_oss_get_active_substream(struct snd_pcm_oss_file *pcm_oss_fil
1069 return err; 1080 return err;
1070 } 1081 }
1071 } 1082 }
1072 snd_assert(asubstream != NULL, return -EIO); 1083 if (!asubstream)
1084 return -EIO;
1073 if (r_substream) 1085 if (r_substream)
1074 *r_substream = asubstream; 1086 *r_substream = asubstream;
1075 return 0; 1087 return 0;
@@ -1764,7 +1776,8 @@ static int snd_pcm_oss_get_formats(struct snd_pcm_oss_file *pcm_oss_file)
1764 err = snd_pcm_hw_refine(substream, params); 1776 err = snd_pcm_hw_refine(substream, params);
1765 format_mask = *hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 1777 format_mask = *hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
1766 kfree(params); 1778 kfree(params);
1767 snd_assert(err >= 0, return err); 1779 if (err < 0)
1780 return err;
1768 for (fmt = 0; fmt < 32; ++fmt) { 1781 for (fmt = 0; fmt < 32; ++fmt) {
1769 if (snd_mask_test(&format_mask, fmt)) { 1782 if (snd_mask_test(&format_mask, fmt)) {
1770 int f = snd_pcm_oss_format_to(fmt); 1783 int f = snd_pcm_oss_format_to(fmt);
@@ -2250,7 +2263,8 @@ static void snd_pcm_oss_init_substream(struct snd_pcm_substream *substream,
2250static int snd_pcm_oss_release_file(struct snd_pcm_oss_file *pcm_oss_file) 2263static int snd_pcm_oss_release_file(struct snd_pcm_oss_file *pcm_oss_file)
2251{ 2264{
2252 int cidx; 2265 int cidx;
2253 snd_assert(pcm_oss_file != NULL, return -ENXIO); 2266 if (!pcm_oss_file)
2267 return 0;
2254 for (cidx = 0; cidx < 2; ++cidx) { 2268 for (cidx = 0; cidx < 2; ++cidx) {
2255 struct snd_pcm_substream *substream = pcm_oss_file->streams[cidx]; 2269 struct snd_pcm_substream *substream = pcm_oss_file->streams[cidx];
2256 if (substream) 2270 if (substream)
@@ -2271,8 +2285,8 @@ static int snd_pcm_oss_open_file(struct file *file,
2271 struct snd_pcm_substream *substream; 2285 struct snd_pcm_substream *substream;
2272 unsigned int f_mode = file->f_mode; 2286 unsigned int f_mode = file->f_mode;
2273 2287
2274 snd_assert(rpcm_oss_file != NULL, return -EINVAL); 2288 if (rpcm_oss_file)
2275 *rpcm_oss_file = NULL; 2289 *rpcm_oss_file = NULL;
2276 2290
2277 pcm_oss_file = kzalloc(sizeof(*pcm_oss_file), GFP_KERNEL); 2291 pcm_oss_file = kzalloc(sizeof(*pcm_oss_file), GFP_KERNEL);
2278 if (pcm_oss_file == NULL) 2292 if (pcm_oss_file == NULL)
@@ -2312,7 +2326,8 @@ static int snd_pcm_oss_open_file(struct file *file,
2312 } 2326 }
2313 2327
2314 file->private_data = pcm_oss_file; 2328 file->private_data = pcm_oss_file;
2315 *rpcm_oss_file = pcm_oss_file; 2329 if (rpcm_oss_file)
2330 *rpcm_oss_file = pcm_oss_file;
2316 return 0; 2331 return 0;
2317} 2332}
2318 2333
@@ -2321,7 +2336,8 @@ static int snd_task_name(struct task_struct *task, char *name, size_t size)
2321{ 2336{
2322 unsigned int idx; 2337 unsigned int idx;
2323 2338
2324 snd_assert(task != NULL && name != NULL && size >= 2, return -EINVAL); 2339 if (snd_BUG_ON(!task || !name || size < 2))
2340 return -EINVAL;
2325 for (idx = 0; idx < sizeof(task->comm) && idx + 1 < size; idx++) 2341 for (idx = 0; idx < sizeof(task->comm) && idx + 1 < size; idx++)
2326 name[idx] = task->comm[idx]; 2342 name[idx] = task->comm[idx];
2327 name[idx] = '\0'; 2343 name[idx] = '\0';
@@ -2415,7 +2431,8 @@ static int snd_pcm_oss_release(struct inode *inode, struct file *file)
2415 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK]; 2431 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_PLAYBACK];
2416 if (substream == NULL) 2432 if (substream == NULL)
2417 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE]; 2433 substream = pcm_oss_file->streams[SNDRV_PCM_STREAM_CAPTURE];
2418 snd_assert(substream != NULL, return -ENXIO); 2434 if (snd_BUG_ON(!substream))
2435 return -ENXIO;
2419 pcm = substream->pcm; 2436 pcm = substream->pcm;
2420 if (!pcm->card->shutdown) 2437 if (!pcm->card->shutdown)
2421 snd_pcm_oss_sync(pcm_oss_file); 2438 snd_pcm_oss_sync(pcm_oss_file);
@@ -2448,7 +2465,8 @@ static long snd_pcm_oss_ioctl(struct file *file, unsigned int cmd, unsigned long
2448 if (substream != NULL) 2465 if (substream != NULL)
2449 break; 2466 break;
2450 } 2467 }
2451 snd_assert(substream != NULL, return -ENXIO); 2468 if (snd_BUG_ON(idx >= 2))
2469 return -ENXIO;
2452 return snd_mixer_oss_ioctl_card(substream->pcm->card, cmd, arg); 2470 return snd_mixer_oss_ioctl_card(substream->pcm->card, cmd, arg);
2453 } 2471 }
2454#endif 2472#endif