aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core/oss/pcm_plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/core/oss/pcm_plugin.c')
-rw-r--r--sound/core/oss/pcm_plugin.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/sound/core/oss/pcm_plugin.c b/sound/core/oss/pcm_plugin.c
index bec94138205e..6751daa3bb50 100644
--- a/sound/core/oss/pcm_plugin.c
+++ b/sound/core/oss/pcm_plugin.c
@@ -62,7 +62,8 @@ static int snd_pcm_plugin_alloc(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t
62 if ((width = snd_pcm_format_physical_width(format->format)) < 0) 62 if ((width = snd_pcm_format_physical_width(format->format)) < 0)
63 return width; 63 return width;
64 size = frames * format->channels * width; 64 size = frames * format->channels * width;
65 snd_assert((size % 8) == 0, return -ENXIO); 65 if (snd_BUG_ON(size % 8))
66 return -ENXIO;
66 size /= 8; 67 size /= 8;
67 if (plugin->buf_frames < frames) { 68 if (plugin->buf_frames < frames) {
68 vfree(plugin->buf); 69 vfree(plugin->buf);
@@ -84,7 +85,8 @@ static int snd_pcm_plugin_alloc(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t
84 c->area.step = format->channels * width; 85 c->area.step = format->channels * width;
85 } 86 }
86 } else if (plugin->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) { 87 } else if (plugin->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
87 snd_assert((size % format->channels) == 0,); 88 if (snd_BUG_ON(size % format->channels))
89 return -EINVAL;
88 size /= format->channels; 90 size /= format->channels;
89 for (channel = 0; channel < format->channels; channel++, c++) { 91 for (channel = 0; channel < format->channels; channel++, c++) {
90 c->frames = frames; 92 c->frames = frames;
@@ -102,13 +104,15 @@ static int snd_pcm_plugin_alloc(struct snd_pcm_plugin *plugin, snd_pcm_uframes_t
102int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames) 104int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames)
103{ 105{
104 int err; 106 int err;
105 snd_assert(snd_pcm_plug_first(plug) != NULL, return -ENXIO); 107 if (snd_BUG_ON(!snd_pcm_plug_first(plug)))
108 return -ENXIO;
106 if (snd_pcm_plug_stream(plug) == SNDRV_PCM_STREAM_PLAYBACK) { 109 if (snd_pcm_plug_stream(plug) == SNDRV_PCM_STREAM_PLAYBACK) {
107 struct snd_pcm_plugin *plugin = snd_pcm_plug_first(plug); 110 struct snd_pcm_plugin *plugin = snd_pcm_plug_first(plug);
108 while (plugin->next) { 111 while (plugin->next) {
109 if (plugin->dst_frames) 112 if (plugin->dst_frames)
110 frames = plugin->dst_frames(plugin, frames); 113 frames = plugin->dst_frames(plugin, frames);
111 snd_assert(frames > 0, return -ENXIO); 114 if (snd_BUG_ON(frames <= 0))
115 return -ENXIO;
112 plugin = plugin->next; 116 plugin = plugin->next;
113 err = snd_pcm_plugin_alloc(plugin, frames); 117 err = snd_pcm_plugin_alloc(plugin, frames);
114 if (err < 0) 118 if (err < 0)
@@ -119,7 +123,8 @@ int snd_pcm_plug_alloc(struct snd_pcm_substream *plug, snd_pcm_uframes_t frames)
119 while (plugin->prev) { 123 while (plugin->prev) {
120 if (plugin->src_frames) 124 if (plugin->src_frames)
121 frames = plugin->src_frames(plugin, frames); 125 frames = plugin->src_frames(plugin, frames);
122 snd_assert(frames > 0, return -ENXIO); 126 if (snd_BUG_ON(frames <= 0))
127 return -ENXIO;
123 plugin = plugin->prev; 128 plugin = plugin->prev;
124 err = snd_pcm_plugin_alloc(plugin, frames); 129 err = snd_pcm_plugin_alloc(plugin, frames);
125 if (err < 0) 130 if (err < 0)
@@ -148,8 +153,10 @@ int snd_pcm_plugin_build(struct snd_pcm_substream *plug,
148 struct snd_pcm_plugin *plugin; 153 struct snd_pcm_plugin *plugin;
149 unsigned int channels; 154 unsigned int channels;
150 155
151 snd_assert(plug != NULL, return -ENXIO); 156 if (snd_BUG_ON(!plug))
152 snd_assert(src_format != NULL && dst_format != NULL, return -ENXIO); 157 return -ENXIO;
158 if (snd_BUG_ON(!src_format || !dst_format))
159 return -ENXIO;
153 plugin = kzalloc(sizeof(*plugin) + extra, GFP_KERNEL); 160 plugin = kzalloc(sizeof(*plugin) + extra, GFP_KERNEL);
154 if (plugin == NULL) 161 if (plugin == NULL)
155 return -ENOMEM; 162 return -ENOMEM;
@@ -159,10 +166,10 @@ int snd_pcm_plugin_build(struct snd_pcm_substream *plug,
159 plugin->access = SNDRV_PCM_ACCESS_RW_INTERLEAVED; 166 plugin->access = SNDRV_PCM_ACCESS_RW_INTERLEAVED;
160 plugin->src_format = *src_format; 167 plugin->src_format = *src_format;
161 plugin->src_width = snd_pcm_format_physical_width(src_format->format); 168 plugin->src_width = snd_pcm_format_physical_width(src_format->format);
162 snd_assert(plugin->src_width > 0, ); 169 snd_BUG_ON(plugin->src_width <= 0);
163 plugin->dst_format = *dst_format; 170 plugin->dst_format = *dst_format;
164 plugin->dst_width = snd_pcm_format_physical_width(dst_format->format); 171 plugin->dst_width = snd_pcm_format_physical_width(dst_format->format);
165 snd_assert(plugin->dst_width > 0, ); 172 snd_BUG_ON(plugin->dst_width <= 0);
166 if (plugin->stream == SNDRV_PCM_STREAM_PLAYBACK) 173 if (plugin->stream == SNDRV_PCM_STREAM_PLAYBACK)
167 channels = src_format->channels; 174 channels = src_format->channels;
168 else 175 else
@@ -194,7 +201,8 @@ snd_pcm_sframes_t snd_pcm_plug_client_size(struct snd_pcm_substream *plug, snd_p
194 struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next; 201 struct snd_pcm_plugin *plugin, *plugin_prev, *plugin_next;
195 int stream = snd_pcm_plug_stream(plug); 202 int stream = snd_pcm_plug_stream(plug);
196 203
197 snd_assert(plug != NULL, return -ENXIO); 204 if (snd_BUG_ON(!plug))
205 return -ENXIO;
198 if (drv_frames == 0) 206 if (drv_frames == 0)
199 return 0; 207 return 0;
200 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 208 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
@@ -224,7 +232,8 @@ snd_pcm_sframes_t snd_pcm_plug_slave_size(struct snd_pcm_substream *plug, snd_pc
224 snd_pcm_sframes_t frames; 232 snd_pcm_sframes_t frames;
225 int stream = snd_pcm_plug_stream(plug); 233 int stream = snd_pcm_plug_stream(plug);
226 234
227 snd_assert(plug != NULL, return -ENXIO); 235 if (snd_BUG_ON(!plug))
236 return -ENXIO;
228 if (clt_frames == 0) 237 if (clt_frames == 0)
229 return 0; 238 return 0;
230 frames = clt_frames; 239 frames = clt_frames;
@@ -540,7 +549,8 @@ snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *plu
540 int width, nchannels, channel; 549 int width, nchannels, channel;
541 int stream = snd_pcm_plug_stream(plug); 550 int stream = snd_pcm_plug_stream(plug);
542 551
543 snd_assert(buf != NULL, return -ENXIO); 552 if (snd_BUG_ON(!buf))
553 return -ENXIO;
544 if (stream == SNDRV_PCM_STREAM_PLAYBACK) { 554 if (stream == SNDRV_PCM_STREAM_PLAYBACK) {
545 plugin = snd_pcm_plug_first(plug); 555 plugin = snd_pcm_plug_first(plug);
546 format = &plugin->src_format; 556 format = &plugin->src_format;
@@ -553,7 +563,9 @@ snd_pcm_sframes_t snd_pcm_plug_client_channels_buf(struct snd_pcm_substream *plu
553 if ((width = snd_pcm_format_physical_width(format->format)) < 0) 563 if ((width = snd_pcm_format_physical_width(format->format)) < 0)
554 return width; 564 return width;
555 nchannels = format->channels; 565 nchannels = format->channels;
556 snd_assert(plugin->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED || format->channels <= 1, return -ENXIO); 566 if (snd_BUG_ON(plugin->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED &&
567 format->channels > 1))
568 return -ENXIO;
557 for (channel = 0; channel < nchannels; channel++, v++) { 569 for (channel = 0; channel < nchannels; channel++, v++) {
558 v->frames = count; 570 v->frames = count;
559 v->enabled = 1; 571 v->enabled = 1;