All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm: mach-omap2: potential NULL dereference
@ 2011-01-17 10:08 ` Vasiliy Kulikov
  0 siblings, 0 replies; 18+ messages in thread
From: Vasiliy Kulikov @ 2011-01-17 10:08 UTC (permalink / raw)
  To: kernel-janitors
  Cc: Tony Lindgren, Russell King, linux-omap, linux-arm-kernel, linux-kernel

If kzalloc() failed, return -ENOMEM.
sr_dev_init() should signal by return value that there is an error.

Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
---
 Cannot compile this driver, so it is not tested at all.

 arch/arm/mach-omap2/sr_device.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/sr_device.c b/arch/arm/mach-omap2/sr_device.c
index b1e0af1..20fccfb 100644
--- a/arch/arm/mach-omap2/sr_device.c
+++ b/arch/arm/mach-omap2/sr_device.c
@@ -40,7 +40,7 @@ static struct omap_device_pm_latency omap_sr_latency[] = {
 };
 
 /* Read EFUSE values from control registers for OMAP3430 */
-static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
+static int __init sr_set_nvalues(struct omap_volt_data *volt_data,
 				struct omap_sr_data *sr_data)
 {
 	struct omap_sr_nvalue_table *nvalue_table;
@@ -51,6 +51,8 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
 
 	nvalue_table = kzalloc(sizeof(struct omap_sr_nvalue_table)*count,
 			GFP_KERNEL);
+	if (nvalue_table == NULL)
+		return -ENOMEM;
 
 	for (i = 0; i < count; i++) {
 		u32 v;
@@ -75,6 +77,8 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
 
 	sr_data->nvalue_table = nvalue_table;
 	sr_data->nvalue_count = count;
+
+	return 0;
 }
 
 static int sr_dev_init(struct omap_hwmod *oh, void *user)
@@ -84,15 +88,18 @@ static int sr_dev_init(struct omap_hwmod *oh, void *user)
 	struct omap_volt_data *volt_data;
 	char *name = "smartreflex";
 	static int i;
+	int err = 0;
 
 	sr_data = kzalloc(sizeof(struct omap_sr_data), GFP_KERNEL);
 	if (!sr_data) {
+		err = -ENOMEM;
 		pr_err("%s: Unable to allocate memory for %s sr_data.Error!\n",
 			__func__, oh->name);
-		return -ENOMEM;
+		goto exit;
 	}
 
 	if (!oh->vdd_name) {
+		err = -EINVAL;
 		pr_err("%s: No voltage domain specified for %s."
 			"Cannot initialize\n", __func__, oh->name);
 		goto exit;
@@ -104,6 +111,7 @@ static int sr_dev_init(struct omap_hwmod *oh, void *user)
 
 	sr_data->voltdm = omap_voltage_domain_lookup(oh->vdd_name);
 	if (IS_ERR(sr_data->voltdm)) {
+		err = PTR_ERR(sr_data->voltdm);
 		pr_err("%s: Unable to get voltage domain pointer for VDD %s\n",
 			__func__, oh->vdd_name);
 		goto exit;
@@ -111,12 +119,15 @@ static int sr_dev_init(struct omap_hwmod *oh, void *user)
 
 	omap_voltage_get_volttable(sr_data->voltdm, &volt_data);
 	if (!volt_data) {
+		err = -EINVAL;
 		pr_warning("%s: No Voltage table registerd fo VDD%d."
 			"Something really wrong\n\n", __func__, i + 1);
 		goto exit;
 	}
 
-	sr_set_nvalues(volt_data, sr_data);
+	err = sr_set_nvalues(volt_data, sr_data);
+	if (err)
+		goto exit;
 
 	sr_data->enable_on_init = sr_enable_on_init;
 
@@ -129,7 +140,7 @@ static int sr_dev_init(struct omap_hwmod *oh, void *user)
 exit:
 	i++;
 	kfree(sr_data);
-	return 0;
+	return err;
 }
 
 /*
-- 
1.7.0.4


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

* [PATCH] arm: mach-omap2: potential NULL dereference
@ 2011-01-17 10:08 ` Vasiliy Kulikov
  0 siblings, 0 replies; 18+ messages in thread
From: Vasiliy Kulikov @ 2011-01-17 10:08 UTC (permalink / raw)
  To: linux-arm-kernel

If kzalloc() failed, return -ENOMEM.
sr_dev_init() should signal by return value that there is an error.

Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
---
 Cannot compile this driver, so it is not tested at all.

 arch/arm/mach-omap2/sr_device.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/sr_device.c b/arch/arm/mach-omap2/sr_device.c
index b1e0af1..20fccfb 100644
--- a/arch/arm/mach-omap2/sr_device.c
+++ b/arch/arm/mach-omap2/sr_device.c
@@ -40,7 +40,7 @@ static struct omap_device_pm_latency omap_sr_latency[] = {
 };
 
 /* Read EFUSE values from control registers for OMAP3430 */
-static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
+static int __init sr_set_nvalues(struct omap_volt_data *volt_data,
 				struct omap_sr_data *sr_data)
 {
 	struct omap_sr_nvalue_table *nvalue_table;
@@ -51,6 +51,8 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
 
 	nvalue_table = kzalloc(sizeof(struct omap_sr_nvalue_table)*count,
 			GFP_KERNEL);
+	if (nvalue_table = NULL)
+		return -ENOMEM;
 
 	for (i = 0; i < count; i++) {
 		u32 v;
@@ -75,6 +77,8 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
 
 	sr_data->nvalue_table = nvalue_table;
 	sr_data->nvalue_count = count;
+
+	return 0;
 }
 
 static int sr_dev_init(struct omap_hwmod *oh, void *user)
@@ -84,15 +88,18 @@ static int sr_dev_init(struct omap_hwmod *oh, void *user)
 	struct omap_volt_data *volt_data;
 	char *name = "smartreflex";
 	static int i;
+	int err = 0;
 
 	sr_data = kzalloc(sizeof(struct omap_sr_data), GFP_KERNEL);
 	if (!sr_data) {
+		err = -ENOMEM;
 		pr_err("%s: Unable to allocate memory for %s sr_data.Error!\n",
 			__func__, oh->name);
-		return -ENOMEM;
+		goto exit;
 	}
 
 	if (!oh->vdd_name) {
+		err = -EINVAL;
 		pr_err("%s: No voltage domain specified for %s."
 			"Cannot initialize\n", __func__, oh->name);
 		goto exit;
@@ -104,6 +111,7 @@ static int sr_dev_init(struct omap_hwmod *oh, void *user)
 
 	sr_data->voltdm = omap_voltage_domain_lookup(oh->vdd_name);
 	if (IS_ERR(sr_data->voltdm)) {
+		err = PTR_ERR(sr_data->voltdm);
 		pr_err("%s: Unable to get voltage domain pointer for VDD %s\n",
 			__func__, oh->vdd_name);
 		goto exit;
@@ -111,12 +119,15 @@ static int sr_dev_init(struct omap_hwmod *oh, void *user)
 
 	omap_voltage_get_volttable(sr_data->voltdm, &volt_data);
 	if (!volt_data) {
+		err = -EINVAL;
 		pr_warning("%s: No Voltage table registerd fo VDD%d."
 			"Something really wrong\n\n", __func__, i + 1);
 		goto exit;
 	}
 
-	sr_set_nvalues(volt_data, sr_data);
+	err = sr_set_nvalues(volt_data, sr_data);
+	if (err)
+		goto exit;
 
 	sr_data->enable_on_init = sr_enable_on_init;
 
@@ -129,7 +140,7 @@ static int sr_dev_init(struct omap_hwmod *oh, void *user)
 exit:
 	i++;
 	kfree(sr_data);
-	return 0;
+	return err;
 }
 
 /*
-- 
1.7.0.4


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

* [PATCH] arm: mach-omap2: potential NULL dereference
@ 2011-01-17 10:08 ` Vasiliy Kulikov
  0 siblings, 0 replies; 18+ messages in thread
From: Vasiliy Kulikov @ 2011-01-17 10:08 UTC (permalink / raw)
  To: linux-arm-kernel

If kzalloc() failed, return -ENOMEM.
sr_dev_init() should signal by return value that there is an error.

Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
---
 Cannot compile this driver, so it is not tested at all.

 arch/arm/mach-omap2/sr_device.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-omap2/sr_device.c b/arch/arm/mach-omap2/sr_device.c
index b1e0af1..20fccfb 100644
--- a/arch/arm/mach-omap2/sr_device.c
+++ b/arch/arm/mach-omap2/sr_device.c
@@ -40,7 +40,7 @@ static struct omap_device_pm_latency omap_sr_latency[] = {
 };
 
 /* Read EFUSE values from control registers for OMAP3430 */
-static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
+static int __init sr_set_nvalues(struct omap_volt_data *volt_data,
 				struct omap_sr_data *sr_data)
 {
 	struct omap_sr_nvalue_table *nvalue_table;
@@ -51,6 +51,8 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
 
 	nvalue_table = kzalloc(sizeof(struct omap_sr_nvalue_table)*count,
 			GFP_KERNEL);
+	if (nvalue_table == NULL)
+		return -ENOMEM;
 
 	for (i = 0; i < count; i++) {
 		u32 v;
@@ -75,6 +77,8 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
 
 	sr_data->nvalue_table = nvalue_table;
 	sr_data->nvalue_count = count;
+
+	return 0;
 }
 
 static int sr_dev_init(struct omap_hwmod *oh, void *user)
@@ -84,15 +88,18 @@ static int sr_dev_init(struct omap_hwmod *oh, void *user)
 	struct omap_volt_data *volt_data;
 	char *name = "smartreflex";
 	static int i;
+	int err = 0;
 
 	sr_data = kzalloc(sizeof(struct omap_sr_data), GFP_KERNEL);
 	if (!sr_data) {
+		err = -ENOMEM;
 		pr_err("%s: Unable to allocate memory for %s sr_data.Error!\n",
 			__func__, oh->name);
-		return -ENOMEM;
+		goto exit;
 	}
 
 	if (!oh->vdd_name) {
+		err = -EINVAL;
 		pr_err("%s: No voltage domain specified for %s."
 			"Cannot initialize\n", __func__, oh->name);
 		goto exit;
@@ -104,6 +111,7 @@ static int sr_dev_init(struct omap_hwmod *oh, void *user)
 
 	sr_data->voltdm = omap_voltage_domain_lookup(oh->vdd_name);
 	if (IS_ERR(sr_data->voltdm)) {
+		err = PTR_ERR(sr_data->voltdm);
 		pr_err("%s: Unable to get voltage domain pointer for VDD %s\n",
 			__func__, oh->vdd_name);
 		goto exit;
@@ -111,12 +119,15 @@ static int sr_dev_init(struct omap_hwmod *oh, void *user)
 
 	omap_voltage_get_volttable(sr_data->voltdm, &volt_data);
 	if (!volt_data) {
+		err = -EINVAL;
 		pr_warning("%s: No Voltage table registerd fo VDD%d."
 			"Something really wrong\n\n", __func__, i + 1);
 		goto exit;
 	}
 
-	sr_set_nvalues(volt_data, sr_data);
+	err = sr_set_nvalues(volt_data, sr_data);
+	if (err)
+		goto exit;
 
 	sr_data->enable_on_init = sr_enable_on_init;
 
@@ -129,7 +140,7 @@ static int sr_dev_init(struct omap_hwmod *oh, void *user)
 exit:
 	i++;
 	kfree(sr_data);
-	return 0;
+	return err;
 }
 
 /*
-- 
1.7.0.4

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

* [PATCH] arm: mach-omap2: potential NULL dereference
  2011-01-17 10:08 ` Vasiliy Kulikov
  (?)
@ 2011-01-17 10:08 ` Vasiliy Kulikov
  -1 siblings, 0 replies; 18+ messages in thread
From: Vasiliy Kulikov @ 2011-01-17 10:08 UTC (permalink / raw)
  To: kernel-janitors
  Cc: Tony Lindgren, Russell King, linux-omap, linux-arm-kernel, linux-kernel

kzalloc() may fail, if so return -ENOMEM.

Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
---
 Cannot compile this driver, so it is not tested at all.

 arch/arm/mach-omap2/smartreflex.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
index 77ecebf..871bca9 100644
--- a/arch/arm/mach-omap2/smartreflex.c
+++ b/arch/arm/mach-omap2/smartreflex.c
@@ -260,7 +260,10 @@ static int sr_late_init(struct omap_sr *sr_info)
 	if (sr_class->class_type == SR_CLASS2 &&
 		sr_class->notify_flags && sr_info->irq) {
 
+		ret = -ENOMEM;
 		name = kzalloc(SMARTREFLEX_NAME_LEN + 1, GFP_KERNEL);
+		if (name == NULL)
+			goto error;
 		strcpy(name, "sr_");
 		strcat(name, sr_info->voltdm->name);
 		ret = request_irq(sr_info->irq, sr_interrupt,
-- 
1.7.0.4


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

* [PATCH] arm: mach-omap2: potential NULL dereference
@ 2011-01-17 10:08 ` Vasiliy Kulikov
  0 siblings, 0 replies; 18+ messages in thread
From: Vasiliy Kulikov @ 2011-01-17 10:08 UTC (permalink / raw)
  To: linux-arm-kernel

kzalloc() may fail, if so return -ENOMEM.

Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
---
 Cannot compile this driver, so it is not tested at all.

 arch/arm/mach-omap2/smartreflex.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
index 77ecebf..871bca9 100644
--- a/arch/arm/mach-omap2/smartreflex.c
+++ b/arch/arm/mach-omap2/smartreflex.c
@@ -260,7 +260,10 @@ static int sr_late_init(struct omap_sr *sr_info)
 	if (sr_class->class_type = SR_CLASS2 &&
 		sr_class->notify_flags && sr_info->irq) {
 
+		ret = -ENOMEM;
 		name = kzalloc(SMARTREFLEX_NAME_LEN + 1, GFP_KERNEL);
+		if (name = NULL)
+			goto error;
 		strcpy(name, "sr_");
 		strcat(name, sr_info->voltdm->name);
 		ret = request_irq(sr_info->irq, sr_interrupt,
-- 
1.7.0.4


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

* [PATCH] arm: mach-omap2: potential NULL dereference
@ 2011-01-17 10:08 ` Vasiliy Kulikov
  0 siblings, 0 replies; 18+ messages in thread
From: Vasiliy Kulikov @ 2011-01-17 10:08 UTC (permalink / raw)
  To: linux-arm-kernel

kzalloc() may fail, if so return -ENOMEM.

Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
---
 Cannot compile this driver, so it is not tested at all.

 arch/arm/mach-omap2/smartreflex.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
index 77ecebf..871bca9 100644
--- a/arch/arm/mach-omap2/smartreflex.c
+++ b/arch/arm/mach-omap2/smartreflex.c
@@ -260,7 +260,10 @@ static int sr_late_init(struct omap_sr *sr_info)
 	if (sr_class->class_type == SR_CLASS2 &&
 		sr_class->notify_flags && sr_info->irq) {
 
+		ret = -ENOMEM;
 		name = kzalloc(SMARTREFLEX_NAME_LEN + 1, GFP_KERNEL);
+		if (name == NULL)
+			goto error;
 		strcpy(name, "sr_");
 		strcat(name, sr_info->voltdm->name);
 		ret = request_irq(sr_info->irq, sr_interrupt,
-- 
1.7.0.4

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

* Re: [PATCH] arm: mach-omap2: potential NULL dereference
  2011-01-17 10:08 ` Vasiliy Kulikov
  (?)
@ 2011-01-17 10:38   ` walter harms
  -1 siblings, 0 replies; 18+ messages in thread
From: walter harms @ 2011-01-17 10:38 UTC (permalink / raw)
  To: Vasiliy Kulikov
  Cc: kernel-janitors, Tony Lindgren, Russell King, linux-omap,
	linux-arm-kernel, linux-kernel



Am 17.01.2011 11:08, schrieb Vasiliy Kulikov:
> kzalloc() may fail, if so return -ENOMEM.
> 
> Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
> ---
>  Cannot compile this driver, so it is not tested at all.
> 
>  arch/arm/mach-omap2/smartreflex.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
> index 77ecebf..871bca9 100644
> --- a/arch/arm/mach-omap2/smartreflex.c
> +++ b/arch/arm/mach-omap2/smartreflex.c
> @@ -260,7 +260,10 @@ static int sr_late_init(struct omap_sr *sr_info)
>  	if (sr_class->class_type == SR_CLASS2 &&
>  		sr_class->notify_flags && sr_info->irq) {
>  
> +		ret = -ENOMEM;
>  		name = kzalloc(SMARTREFLEX_NAME_LEN + 1, GFP_KERNEL);
> +		if (name == NULL)
> +			goto error;
>  		strcpy(name, "sr_");
>  		strcat(name, sr_info->voltdm->name);
>  		ret = request_irq(sr_info->irq, sr_interrupt,

maybe it is more readable to use:
	kasprint(&name,"sr_%s",sr_info->voltdm->name);

re,
 wh

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

* Re: [PATCH] arm: mach-omap2: potential NULL dereference
@ 2011-01-17 10:38   ` walter harms
  0 siblings, 0 replies; 18+ messages in thread
From: walter harms @ 2011-01-17 10:38 UTC (permalink / raw)
  To: linux-arm-kernel



Am 17.01.2011 11:08, schrieb Vasiliy Kulikov:
> kzalloc() may fail, if so return -ENOMEM.
> 
> Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
> ---
>  Cannot compile this driver, so it is not tested at all.
> 
>  arch/arm/mach-omap2/smartreflex.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
> index 77ecebf..871bca9 100644
> --- a/arch/arm/mach-omap2/smartreflex.c
> +++ b/arch/arm/mach-omap2/smartreflex.c
> @@ -260,7 +260,10 @@ static int sr_late_init(struct omap_sr *sr_info)
>  	if (sr_class->class_type = SR_CLASS2 &&
>  		sr_class->notify_flags && sr_info->irq) {
>  
> +		ret = -ENOMEM;
>  		name = kzalloc(SMARTREFLEX_NAME_LEN + 1, GFP_KERNEL);
> +		if (name = NULL)
> +			goto error;
>  		strcpy(name, "sr_");
>  		strcat(name, sr_info->voltdm->name);
>  		ret = request_irq(sr_info->irq, sr_interrupt,

maybe it is more readable to use:
	kasprint(&name,"sr_%s",sr_info->voltdm->name);

re,
 wh

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

* [PATCH] arm: mach-omap2: potential NULL dereference
@ 2011-01-17 10:38   ` walter harms
  0 siblings, 0 replies; 18+ messages in thread
From: walter harms @ 2011-01-17 10:38 UTC (permalink / raw)
  To: linux-arm-kernel



Am 17.01.2011 11:08, schrieb Vasiliy Kulikov:
> kzalloc() may fail, if so return -ENOMEM.
> 
> Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
> ---
>  Cannot compile this driver, so it is not tested at all.
> 
>  arch/arm/mach-omap2/smartreflex.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
> index 77ecebf..871bca9 100644
> --- a/arch/arm/mach-omap2/smartreflex.c
> +++ b/arch/arm/mach-omap2/smartreflex.c
> @@ -260,7 +260,10 @@ static int sr_late_init(struct omap_sr *sr_info)
>  	if (sr_class->class_type == SR_CLASS2 &&
>  		sr_class->notify_flags && sr_info->irq) {
>  
> +		ret = -ENOMEM;
>  		name = kzalloc(SMARTREFLEX_NAME_LEN + 1, GFP_KERNEL);
> +		if (name == NULL)
> +			goto error;
>  		strcpy(name, "sr_");
>  		strcat(name, sr_info->voltdm->name);
>  		ret = request_irq(sr_info->irq, sr_interrupt,

maybe it is more readable to use:
	kasprint(&name,"sr_%s",sr_info->voltdm->name);

re,
 wh

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

* Re: [PATCH] arm: mach-omap2: potential NULL dereference
  2011-01-17 10:08 ` Vasiliy Kulikov
  (?)
@ 2011-01-17 12:30   ` Sergei Shtylyov
  -1 siblings, 0 replies; 18+ messages in thread
From: Sergei Shtylyov @ 2011-01-17 12:30 UTC (permalink / raw)
  To: Vasiliy Kulikov
  Cc: kernel-janitors, Tony Lindgren, linux-omap, Russell King,
	linux-kernel, linux-arm-kernel

Hello.

On 17-01-2011 13:08, Vasiliy Kulikov wrote:

> kzalloc() may fail, if so return -ENOMEM.

> Signed-off-by: Vasiliy Kulikov<segoon@openwall.com>
[...]

> diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
> index 77ecebf..871bca9 100644
> --- a/arch/arm/mach-omap2/smartreflex.c
> +++ b/arch/arm/mach-omap2/smartreflex.c
> @@ -260,7 +260,10 @@ static int sr_late_init(struct omap_sr *sr_info)
>   	if (sr_class->class_type == SR_CLASS2&&
>   		sr_class->notify_flags&&  sr_info->irq) {
>
> +		ret = -ENOMEM;
>   		name = kzalloc(SMARTREFLEX_NAME_LEN + 1, GFP_KERNEL);
> +		if (name == NULL)
> +			goto error;

    Why not:

		if (name == NULL) {
			ret = -ENOMEM;
			goto error;
		}

WBR, Sergei

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

* Re: [PATCH] arm: mach-omap2: potential NULL dereference
@ 2011-01-17 12:30   ` Sergei Shtylyov
  0 siblings, 0 replies; 18+ messages in thread
From: Sergei Shtylyov @ 2011-01-17 12:30 UTC (permalink / raw)
  To: linux-arm-kernel

Hello.

On 17-01-2011 13:08, Vasiliy Kulikov wrote:

> kzalloc() may fail, if so return -ENOMEM.

> Signed-off-by: Vasiliy Kulikov<segoon@openwall.com>
[...]

> diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
> index 77ecebf..871bca9 100644
> --- a/arch/arm/mach-omap2/smartreflex.c
> +++ b/arch/arm/mach-omap2/smartreflex.c
> @@ -260,7 +260,10 @@ static int sr_late_init(struct omap_sr *sr_info)
>   	if (sr_class->class_type = SR_CLASS2&&
>   		sr_class->notify_flags&&  sr_info->irq) {
>
> +		ret = -ENOMEM;
>   		name = kzalloc(SMARTREFLEX_NAME_LEN + 1, GFP_KERNEL);
> +		if (name = NULL)
> +			goto error;

    Why not:

		if (name = NULL) {
			ret = -ENOMEM;
			goto error;
		}

WBR, Sergei

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

* [PATCH] arm: mach-omap2: potential NULL dereference
@ 2011-01-17 12:30   ` Sergei Shtylyov
  0 siblings, 0 replies; 18+ messages in thread
From: Sergei Shtylyov @ 2011-01-17 12:30 UTC (permalink / raw)
  To: linux-arm-kernel

Hello.

On 17-01-2011 13:08, Vasiliy Kulikov wrote:

> kzalloc() may fail, if so return -ENOMEM.

> Signed-off-by: Vasiliy Kulikov<segoon@openwall.com>
[...]

> diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
> index 77ecebf..871bca9 100644
> --- a/arch/arm/mach-omap2/smartreflex.c
> +++ b/arch/arm/mach-omap2/smartreflex.c
> @@ -260,7 +260,10 @@ static int sr_late_init(struct omap_sr *sr_info)
>   	if (sr_class->class_type == SR_CLASS2&&
>   		sr_class->notify_flags&&  sr_info->irq) {
>
> +		ret = -ENOMEM;
>   		name = kzalloc(SMARTREFLEX_NAME_LEN + 1, GFP_KERNEL);
> +		if (name == NULL)
> +			goto error;

    Why not:

		if (name == NULL) {
			ret = -ENOMEM;
			goto error;
		}

WBR, Sergei

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

* [PATCH v2] arm: mach-omap2: potential NULL dereference
  2011-01-17 10:38   ` walter harms
  (?)
@ 2011-01-19 12:57     ` Vasiliy Kulikov
  -1 siblings, 0 replies; 18+ messages in thread
From: Vasiliy Kulikov @ 2011-01-19 12:57 UTC (permalink / raw)
  To: linux-kernel
  Cc: walter harms, kernel-janitors, Tony Lindgren, Russell King,
	linux-omap, linux-arm-kernel

kzalloc() may fail, if so return -ENOMEM.  Also Walter Harms suggested
to use kasprintf() instead of kzalloc+strcpy+strcat.

Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
---
 Cannot compile this driver, so it is not tested at all.

 arch/arm/mach-omap2/smartreflex.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
index 77ecebf..697d8d4 100644
--- a/arch/arm/mach-omap2/smartreflex.c
+++ b/arch/arm/mach-omap2/smartreflex.c
@@ -260,9 +260,11 @@ static int sr_late_init(struct omap_sr *sr_info)
 	if (sr_class->class_type == SR_CLASS2 &&
 		sr_class->notify_flags && sr_info->irq) {
 
-		name = kzalloc(SMARTREFLEX_NAME_LEN + 1, GFP_KERNEL);
-		strcpy(name, "sr_");
-		strcat(name, sr_info->voltdm->name);
+		name = kasprintf(GFP_KERNEL, "sr_%s", sr_info->voltdm->name);
+		if (name == NULL) {
+			ret = -ENOMEM;
+			goto error;
+		}
 		ret = request_irq(sr_info->irq, sr_interrupt,
 				0, name, (void *)sr_info);
 		if (ret)
-- 
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments

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

* [PATCH v2] arm: mach-omap2: potential NULL dereference
@ 2011-01-19 12:57     ` Vasiliy Kulikov
  0 siblings, 0 replies; 18+ messages in thread
From: Vasiliy Kulikov @ 2011-01-19 12:57 UTC (permalink / raw)
  To: linux-arm-kernel

kzalloc() may fail, if so return -ENOMEM.  Also Walter Harms suggested
to use kasprintf() instead of kzalloc+strcpy+strcat.

Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
---
 Cannot compile this driver, so it is not tested at all.

 arch/arm/mach-omap2/smartreflex.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
index 77ecebf..697d8d4 100644
--- a/arch/arm/mach-omap2/smartreflex.c
+++ b/arch/arm/mach-omap2/smartreflex.c
@@ -260,9 +260,11 @@ static int sr_late_init(struct omap_sr *sr_info)
 	if (sr_class->class_type = SR_CLASS2 &&
 		sr_class->notify_flags && sr_info->irq) {
 
-		name = kzalloc(SMARTREFLEX_NAME_LEN + 1, GFP_KERNEL);
-		strcpy(name, "sr_");
-		strcat(name, sr_info->voltdm->name);
+		name = kasprintf(GFP_KERNEL, "sr_%s", sr_info->voltdm->name);
+		if (name = NULL) {
+			ret = -ENOMEM;
+			goto error;
+		}
 		ret = request_irq(sr_info->irq, sr_interrupt,
 				0, name, (void *)sr_info);
 		if (ret)
-- 
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments

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

* [PATCH v2] arm: mach-omap2: potential NULL dereference
@ 2011-01-19 12:57     ` Vasiliy Kulikov
  0 siblings, 0 replies; 18+ messages in thread
From: Vasiliy Kulikov @ 2011-01-19 12:57 UTC (permalink / raw)
  To: linux-arm-kernel

kzalloc() may fail, if so return -ENOMEM.  Also Walter Harms suggested
to use kasprintf() instead of kzalloc+strcpy+strcat.

Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
---
 Cannot compile this driver, so it is not tested at all.

 arch/arm/mach-omap2/smartreflex.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
index 77ecebf..697d8d4 100644
--- a/arch/arm/mach-omap2/smartreflex.c
+++ b/arch/arm/mach-omap2/smartreflex.c
@@ -260,9 +260,11 @@ static int sr_late_init(struct omap_sr *sr_info)
 	if (sr_class->class_type == SR_CLASS2 &&
 		sr_class->notify_flags && sr_info->irq) {
 
-		name = kzalloc(SMARTREFLEX_NAME_LEN + 1, GFP_KERNEL);
-		strcpy(name, "sr_");
-		strcat(name, sr_info->voltdm->name);
+		name = kasprintf(GFP_KERNEL, "sr_%s", sr_info->voltdm->name);
+		if (name == NULL) {
+			ret = -ENOMEM;
+			goto error;
+		}
 		ret = request_irq(sr_info->irq, sr_interrupt,
 				0, name, (void *)sr_info);
 		if (ret)
-- 
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments

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

* Re: [PATCH v2] arm: mach-omap2: potential NULL dereference
  2011-01-19 12:57     ` Vasiliy Kulikov
  (?)
@ 2011-02-01 22:22       ` Kevin Hilman
  -1 siblings, 0 replies; 18+ messages in thread
From: Kevin Hilman @ 2011-02-01 22:22 UTC (permalink / raw)
  To: Vasiliy Kulikov
  Cc: linux-kernel, walter harms, kernel-janitors, Tony Lindgren,
	Russell King, linux-omap, linux-arm-kernel

Vasiliy Kulikov <segoon@openwall.com> writes:

> kzalloc() may fail, if so return -ENOMEM.  Also Walter Harms suggested
> to use kasprintf() instead of kzalloc+strcpy+strcat.
>
> Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
> ---
>  Cannot compile this driver, so it is not tested at all.

Boot tested on 3430/n900 and 3630/Zoom3.

Queueing for 2.6.39 (branch: for_2.6.39/pm-misc)

Kevin

>  arch/arm/mach-omap2/smartreflex.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
> index 77ecebf..697d8d4 100644
> --- a/arch/arm/mach-omap2/smartreflex.c
> +++ b/arch/arm/mach-omap2/smartreflex.c
> @@ -260,9 +260,11 @@ static int sr_late_init(struct omap_sr *sr_info)
>  	if (sr_class->class_type == SR_CLASS2 &&
>  		sr_class->notify_flags && sr_info->irq) {
>  
> -		name = kzalloc(SMARTREFLEX_NAME_LEN + 1, GFP_KERNEL);
> -		strcpy(name, "sr_");
> -		strcat(name, sr_info->voltdm->name);
> +		name = kasprintf(GFP_KERNEL, "sr_%s", sr_info->voltdm->name);
> +		if (name == NULL) {
> +			ret = -ENOMEM;
> +			goto error;
> +		}
>  		ret = request_irq(sr_info->irq, sr_interrupt,
>  				0, name, (void *)sr_info);
>  		if (ret)

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

* Re: [PATCH v2] arm: mach-omap2: potential NULL dereference
@ 2011-02-01 22:22       ` Kevin Hilman
  0 siblings, 0 replies; 18+ messages in thread
From: Kevin Hilman @ 2011-02-01 22:22 UTC (permalink / raw)
  To: linux-arm-kernel

Vasiliy Kulikov <segoon@openwall.com> writes:

> kzalloc() may fail, if so return -ENOMEM.  Also Walter Harms suggested
> to use kasprintf() instead of kzalloc+strcpy+strcat.
>
> Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
> ---
>  Cannot compile this driver, so it is not tested at all.

Boot tested on 3430/n900 and 3630/Zoom3.

Queueing for 2.6.39 (branch: for_2.6.39/pm-misc)

Kevin

>  arch/arm/mach-omap2/smartreflex.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
> index 77ecebf..697d8d4 100644
> --- a/arch/arm/mach-omap2/smartreflex.c
> +++ b/arch/arm/mach-omap2/smartreflex.c
> @@ -260,9 +260,11 @@ static int sr_late_init(struct omap_sr *sr_info)
>  	if (sr_class->class_type = SR_CLASS2 &&
>  		sr_class->notify_flags && sr_info->irq) {
>  
> -		name = kzalloc(SMARTREFLEX_NAME_LEN + 1, GFP_KERNEL);
> -		strcpy(name, "sr_");
> -		strcat(name, sr_info->voltdm->name);
> +		name = kasprintf(GFP_KERNEL, "sr_%s", sr_info->voltdm->name);
> +		if (name = NULL) {
> +			ret = -ENOMEM;
> +			goto error;
> +		}
>  		ret = request_irq(sr_info->irq, sr_interrupt,
>  				0, name, (void *)sr_info);
>  		if (ret)

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

* [PATCH v2] arm: mach-omap2: potential NULL dereference
@ 2011-02-01 22:22       ` Kevin Hilman
  0 siblings, 0 replies; 18+ messages in thread
From: Kevin Hilman @ 2011-02-01 22:22 UTC (permalink / raw)
  To: linux-arm-kernel

Vasiliy Kulikov <segoon@openwall.com> writes:

> kzalloc() may fail, if so return -ENOMEM.  Also Walter Harms suggested
> to use kasprintf() instead of kzalloc+strcpy+strcat.
>
> Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
> ---
>  Cannot compile this driver, so it is not tested at all.

Boot tested on 3430/n900 and 3630/Zoom3.

Queueing for 2.6.39 (branch: for_2.6.39/pm-misc)

Kevin

>  arch/arm/mach-omap2/smartreflex.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/smartreflex.c b/arch/arm/mach-omap2/smartreflex.c
> index 77ecebf..697d8d4 100644
> --- a/arch/arm/mach-omap2/smartreflex.c
> +++ b/arch/arm/mach-omap2/smartreflex.c
> @@ -260,9 +260,11 @@ static int sr_late_init(struct omap_sr *sr_info)
>  	if (sr_class->class_type == SR_CLASS2 &&
>  		sr_class->notify_flags && sr_info->irq) {
>  
> -		name = kzalloc(SMARTREFLEX_NAME_LEN + 1, GFP_KERNEL);
> -		strcpy(name, "sr_");
> -		strcat(name, sr_info->voltdm->name);
> +		name = kasprintf(GFP_KERNEL, "sr_%s", sr_info->voltdm->name);
> +		if (name == NULL) {
> +			ret = -ENOMEM;
> +			goto error;
> +		}
>  		ret = request_irq(sr_info->irq, sr_interrupt,
>  				0, name, (void *)sr_info);
>  		if (ret)

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

end of thread, other threads:[~2011-02-01 22:22 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-17 10:08 [PATCH] arm: mach-omap2: potential NULL dereference Vasiliy Kulikov
2011-01-17 10:08 ` Vasiliy Kulikov
2011-01-17 10:08 ` Vasiliy Kulikov
2011-01-17 10:38 ` walter harms
2011-01-17 10:38   ` walter harms
2011-01-17 10:38   ` walter harms
2011-01-19 12:57   ` [PATCH v2] " Vasiliy Kulikov
2011-01-19 12:57     ` Vasiliy Kulikov
2011-01-19 12:57     ` Vasiliy Kulikov
2011-02-01 22:22     ` Kevin Hilman
2011-02-01 22:22       ` Kevin Hilman
2011-02-01 22:22       ` Kevin Hilman
2011-01-17 12:30 ` [PATCH] " Sergei Shtylyov
2011-01-17 12:30   ` Sergei Shtylyov
2011-01-17 12:30   ` Sergei Shtylyov
  -- strict thread matches above, loose matches on Subject: below --
2011-01-17 10:08 Vasiliy Kulikov
2011-01-17 10:08 ` Vasiliy Kulikov
2011-01-17 10:08 ` Vasiliy Kulikov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.