alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: Check list debugfs files for PAGE_SIZE overflow
@ 2010-10-13  9:46 Mark Brown
  2010-10-13  9:51 ` Liam Girdwood
  2010-10-15 10:06 ` Liam Girdwood
  0 siblings, 2 replies; 4+ messages in thread
From: Mark Brown @ 2010-10-13  9:46 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: alsa-devel, patches, Mark Brown

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
---
 sound/soc/soc-core.c |   51 ++++++++++++++++++++++++++++++++++---------------
 1 files changed, 35 insertions(+), 16 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index dc1c567..4cbfe46 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -275,15 +275,22 @@ static ssize_t codec_list_read_file(struct file *file, char __user *user_buf,
 				    size_t count, loff_t *ppos)
 {
 	char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
-	ssize_t ret = 0;
+	ssize_t len, ret = 0;
 	struct snd_soc_codec *codec;
 
 	if (!buf)
 		return -ENOMEM;
 
-	list_for_each_entry(codec, &codec_list, list)
-		ret += snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
-				codec->name);
+	list_for_each_entry(codec, &codec_list, list) {
+		len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
+			       codec->name);
+		if (len >= 0)
+			ret += len;
+		if (ret > PAGE_SIZE) {
+			ret = PAGE_SIZE;
+			break;
+		}
+	}
 
 	if (ret >= 0)
 		ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
@@ -302,17 +309,23 @@ static ssize_t dai_list_read_file(struct file *file, char __user *user_buf,
 				  size_t count, loff_t *ppos)
 {
 	char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
-	ssize_t ret = 0;
+	ssize_t len, ret = 0;
 	struct snd_soc_dai *dai;
 
 	if (!buf)
 		return -ENOMEM;
 
-	list_for_each_entry(dai, &dai_list, list)
-		ret += snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", dai->name);
+	list_for_each_entry(dai, &dai_list, list) {
+		len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", dai->name);
+		if (len >= 0)
+			ret += len;
+		if (ret > PAGE_SIZE) {
+			ret = PAGE_SIZE;
+			break;
+		}
+	}
 
-	if (ret >= 0)
-		ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
+	ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
 
 	kfree(buf);
 
@@ -329,18 +342,24 @@ static ssize_t platform_list_read_file(struct file *file,
 				       size_t count, loff_t *ppos)
 {
 	char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
-	ssize_t ret = 0;
+	ssize_t len, ret = 0;
 	struct snd_soc_platform *platform;
 
 	if (!buf)
 		return -ENOMEM;
 
-	list_for_each_entry(platform, &platform_list, list)
-		ret += snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
-				platform->name);
+	list_for_each_entry(platform, &platform_list, list) {
+		len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
+			       platform->name);
+		if (len >= 0)
+			ret += len;
+		if (ret > PAGE_SIZE) {
+			ret = PAGE_SIZE;
+			break;
+		}
+	}
 
-	if (ret >= 0)
-		ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
+	ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
 
 	kfree(buf);
 
@@ -3015,11 +3034,11 @@ int snd_soc_register_dais(struct device *dev,
 		}
 
 		dai->dev = dev;
+		dai->driver = &dai_drv[i];
 		if (dai->driver->id)
 			dai->id = dai->driver->id;
 		else
 			dai->id = i;
-		dai->driver = &dai_drv[i];
 		if (!dai->driver->ops)
 			dai->driver->ops = &null_dai_ops;
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: Check list debugfs files for PAGE_SIZE overflow
  2010-10-13  9:46 [PATCH] ASoC: Check list debugfs files for PAGE_SIZE overflow Mark Brown
@ 2010-10-13  9:51 ` Liam Girdwood
  2010-10-13  9:58   ` Mark Brown
  2010-10-15 10:06 ` Liam Girdwood
  1 sibling, 1 reply; 4+ messages in thread
From: Liam Girdwood @ 2010-10-13  9:51 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, patches

On Wed, 2010-10-13 at 10:46 +0100, Mark Brown wrote:
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
>  sound/soc/soc-core.c |   51 ++++++++++++++++++++++++++++++++++---------------
>  1 files changed, 35 insertions(+), 16 deletions(-)
> 
> diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
> index dc1c567..4cbfe46 100644
> --- a/sound/soc/soc-core.c
> +++ b/sound/soc/soc-core.c
> @@ -275,15 +275,22 @@ static ssize_t codec_list_read_file(struct file *file, char __user *user_buf,
>  				    size_t count, loff_t *ppos)
>  {
>  	char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
> -	ssize_t ret = 0;
> +	ssize_t len, ret = 0;
>  	struct snd_soc_codec *codec;
>  
>  	if (!buf)
>  		return -ENOMEM;
>  
> -	list_for_each_entry(codec, &codec_list, list)
> -		ret += snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
> -				codec->name);
> +	list_for_each_entry(codec, &codec_list, list) {
> +		len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
> +			       codec->name);
> +		if (len >= 0)
> +			ret += len;
> +		if (ret > PAGE_SIZE) {
> +			ret = PAGE_SIZE;
> +			break;
> +		}
> +	}
>  
>  	if (ret >= 0)
>  		ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
> @@ -302,17 +309,23 @@ static ssize_t dai_list_read_file(struct file *file, char __user *user_buf,
>  				  size_t count, loff_t *ppos)
>  {
>  	char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
> -	ssize_t ret = 0;
> +	ssize_t len, ret = 0;
>  	struct snd_soc_dai *dai;
>  
>  	if (!buf)
>  		return -ENOMEM;
>  
> -	list_for_each_entry(dai, &dai_list, list)
> -		ret += snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", dai->name);
> +	list_for_each_entry(dai, &dai_list, list) {
> +		len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", dai->name);
> +		if (len >= 0)
> +			ret += len;
> +		if (ret > PAGE_SIZE) {
> +			ret = PAGE_SIZE;
> +			break;
> +		}
> +	}
>  
> -	if (ret >= 0)
> -		ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
> +	ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
>  
>  	kfree(buf);
>  
> @@ -329,18 +342,24 @@ static ssize_t platform_list_read_file(struct file *file,
>  				       size_t count, loff_t *ppos)
>  {
>  	char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
> -	ssize_t ret = 0;
> +	ssize_t len, ret = 0;
>  	struct snd_soc_platform *platform;
>  
>  	if (!buf)
>  		return -ENOMEM;
>  
> -	list_for_each_entry(platform, &platform_list, list)
> -		ret += snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
> -				platform->name);
> +	list_for_each_entry(platform, &platform_list, list) {
> +		len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n",
> +			       platform->name);
> +		if (len >= 0)
> +			ret += len;
> +		if (ret > PAGE_SIZE) {
> +			ret = PAGE_SIZE;
> +			break;
> +		}
> +	}
>  
> -	if (ret >= 0)
> -		ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
> +	ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
>  
>  	kfree(buf);
>  
> @@ -3015,11 +3034,11 @@ int snd_soc_register_dais(struct device *dev,
>  		}
>  
>  		dai->dev = dev;
> +		dai->driver = &dai_drv[i];
>  		if (dai->driver->id)
>  			dai->id = dai->driver->id;
>  		else
>  			dai->id = i;
> -		dai->driver = &dai_drv[i];
>  		if (!dai->driver->ops)
>  			dai->driver->ops = &null_dai_ops;
>  

Looks like you have the DAI id fix in here too. I assume this is mean to
be a separate patch ?

Liam
-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: Check list debugfs files for PAGE_SIZE overflow
  2010-10-13  9:51 ` Liam Girdwood
@ 2010-10-13  9:58   ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2010-10-13  9:58 UTC (permalink / raw)
  To: Liam Girdwood; +Cc: alsa-devel, patches

On Wed, Oct 13, 2010 at 10:51:03AM +0100, Liam Girdwood wrote:

> Looks like you have the DAI id fix in here too. I assume this is mean to
> be a separate patch ?

That's git stash misbehaving.  Fixed up locally.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ASoC: Check list debugfs files for PAGE_SIZE overflow
  2010-10-13  9:46 [PATCH] ASoC: Check list debugfs files for PAGE_SIZE overflow Mark Brown
  2010-10-13  9:51 ` Liam Girdwood
@ 2010-10-15 10:06 ` Liam Girdwood
  1 sibling, 0 replies; 4+ messages in thread
From: Liam Girdwood @ 2010-10-15 10:06 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, patches

On Wed, 2010-10-13 at 10:46 +0100, Mark Brown wrote:
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
>  sound/soc/soc-core.c |   51 ++++++++++++++++++++++++++++++++++---------------
>  1 files changed, 35 insertions(+), 16 deletions(-)

Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
-- 
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-10-15 10:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-13  9:46 [PATCH] ASoC: Check list debugfs files for PAGE_SIZE overflow Mark Brown
2010-10-13  9:51 ` Liam Girdwood
2010-10-13  9:58   ` Mark Brown
2010-10-15 10:06 ` Liam Girdwood

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).