aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/soc-core.c49
1 files changed, 34 insertions, 15 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 225b5bd2802e..6cee97e23da6 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -274,15 +274,22 @@ static ssize_t codec_list_read_file(struct file *file, char __user *user_buf,
274 size_t count, loff_t *ppos) 274 size_t count, loff_t *ppos)
275{ 275{
276 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); 276 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
277 ssize_t ret = 0; 277 ssize_t len, ret = 0;
278 struct snd_soc_codec *codec; 278 struct snd_soc_codec *codec;
279 279
280 if (!buf) 280 if (!buf)
281 return -ENOMEM; 281 return -ENOMEM;
282 282
283 list_for_each_entry(codec, &codec_list, list) 283 list_for_each_entry(codec, &codec_list, list) {
284 ret += snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", 284 len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
285 codec->name); 285 codec->name);
286 if (len >= 0)
287 ret += len;
288 if (ret > PAGE_SIZE) {
289 ret = PAGE_SIZE;
290 break;
291 }
292 }
286 293
287 if (ret >= 0) 294 if (ret >= 0)
288 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); 295 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
@@ -301,17 +308,23 @@ static ssize_t dai_list_read_file(struct file *file, char __user *user_buf,
301 size_t count, loff_t *ppos) 308 size_t count, loff_t *ppos)
302{ 309{
303 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); 310 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
304 ssize_t ret = 0; 311 ssize_t len, ret = 0;
305 struct snd_soc_dai *dai; 312 struct snd_soc_dai *dai;
306 313
307 if (!buf) 314 if (!buf)
308 return -ENOMEM; 315 return -ENOMEM;
309 316
310 list_for_each_entry(dai, &dai_list, list) 317 list_for_each_entry(dai, &dai_list, list) {
311 ret += snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", dai->name); 318 len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", dai->name);
319 if (len >= 0)
320 ret += len;
321 if (ret > PAGE_SIZE) {
322 ret = PAGE_SIZE;
323 break;
324 }
325 }
312 326
313 if (ret >= 0) 327 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
314 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
315 328
316 kfree(buf); 329 kfree(buf);
317 330
@@ -328,18 +341,24 @@ static ssize_t platform_list_read_file(struct file *file,
328 size_t count, loff_t *ppos) 341 size_t count, loff_t *ppos)
329{ 342{
330 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); 343 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
331 ssize_t ret = 0; 344 ssize_t len, ret = 0;
332 struct snd_soc_platform *platform; 345 struct snd_soc_platform *platform;
333 346
334 if (!buf) 347 if (!buf)
335 return -ENOMEM; 348 return -ENOMEM;
336 349
337 list_for_each_entry(platform, &platform_list, list) 350 list_for_each_entry(platform, &platform_list, list) {
338 ret += snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", 351 len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
339 platform->name); 352 platform->name);
353 if (len >= 0)
354 ret += len;
355 if (ret > PAGE_SIZE) {
356 ret = PAGE_SIZE;
357 break;
358 }
359 }
340 360
341 if (ret >= 0) 361 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
342 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
343 362
344 kfree(buf); 363 kfree(buf);
345 364