linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] OMAP2/3: Keypad: Fix memory leak
@ 2010-05-20 14:29 Manjunatha GK
  2010-05-20 14:29 ` [PATCH] OMAP: McSPI: Fix Null pointer check Manjunatha GK
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Manjunatha GK @ 2010-05-20 14:29 UTC (permalink / raw)
  To: linux-omap; +Cc: Damodar, Tony Lindgren

From: Damodar <x0132156@ti.com>

This patch corrects Possible memory leak of 'input' allocated
through input_allocate_device and Suspicious dereference of pointer 'pdata'
before NULL check

Signed-off-by: Damodar Santhapuri <x0132156@ti.com>
Signed-off-by: Manjunatha GK <manjugk@ti.com>
Cc: Tony Lindgren <tony@atomide.com>

---
 drivers/input/keyboard/twl4030_keypad.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c
index 7aa59e0..aa13aec 100644
--- a/drivers/input/keyboard/twl4030_keypad.c
+++ b/drivers/input/keyboard/twl4030_keypad.c
@@ -326,30 +326,34 @@ static int __devinit twl4030_kp_program(struct twl4030_keypad *kp)
  */
 static int __devinit twl4030_kp_probe(struct platform_device *pdev)
 {
-	struct twl4030_keypad_data *pdata = pdev->dev.platform_data;
-	const struct matrix_keymap_data *keymap_data = pdata->keymap_data;
+	struct twl4030_keypad_data *pdata;
+	const struct matrix_keymap_data *keymap_data;
 	struct twl4030_keypad *kp;
 	struct input_dev *input;
 	u8 reg;
 	int error;
-
+	if (!pdev) {
+		printk(KERN_ERR "Invalid platorm_device\n");
+		return -EINVAL;
+	}
+	pdata = pdev->dev.platform_data;
 	if (!pdata || !pdata->rows || !pdata->cols ||
 	    pdata->rows > TWL4030_MAX_ROWS || pdata->cols > TWL4030_MAX_COLS) {
 		dev_err(&pdev->dev, "Invalid platform_data\n");
 		return -EINVAL;
 	}
-
+	keymap_data = pdata->keymap_data;
 	kp = kzalloc(sizeof(*kp), GFP_KERNEL);
+	if (!kp)
+		return  -ENOMEM;
 	input = input_allocate_device();
-	if (!kp || !input) {
+	if (!input) {
 		error = -ENOMEM;
-		goto err1;
+		goto err0;
 	}
-
 	/* Get the debug Device */
 	kp->dbg_dev = &pdev->dev;
 	kp->input = input;
-
 	kp->n_rows = pdata->rows;
 	kp->n_cols = pdata->cols;
 	kp->irq = platform_get_irq(pdev, 0);
@@ -424,6 +428,7 @@ err2:
 	input = NULL;
 err1:
 	input_free_device(input);
+err0:
 	kfree(kp);
 	return error;
 }
-- 
1.7.0.4


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

* [PATCH] OMAP: McSPI: Fix Null pointer check
  2010-05-20 14:29 [PATCH] OMAP2/3: Keypad: Fix memory leak Manjunatha GK
@ 2010-05-20 14:29 ` Manjunatha GK
  2010-05-20 14:29 ` [PATCH] OMAP: FB: " Manjunatha GK
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Manjunatha GK @ 2010-05-20 14:29 UTC (permalink / raw)
  To: linux-omap; +Cc: Satish, Tony Lindgren

From: Satish <x0124230@ti.com>

Fix Null pointer check for pointer r in omap2_mcspi_remove() function.

Signed-off-by: Satish Kumar <x0124230@ti.com>
Signed-off-by: Manjunatha GK <manjugk@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
---
 drivers/spi/omap2_mcspi.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/spi/omap2_mcspi.c b/drivers/spi/omap2_mcspi.c
index e0de0d0..a95d306 100644
--- a/drivers/spi/omap2_mcspi.c
+++ b/drivers/spi/omap2_mcspi.c
@@ -1198,6 +1198,8 @@ static int __exit omap2_mcspi_remove(struct platform_device *pdev)
 	clk_put(mcspi->ick);
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (r == NULL)
+		return -EINVAL;
 	release_mem_region(r->start, (r->end - r->start) + 1);
 
 	base = mcspi->base;
-- 
1.7.0.4


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

* [PATCH] OMAP: FB: Fix Null pointer check
  2010-05-20 14:29 [PATCH] OMAP2/3: Keypad: Fix memory leak Manjunatha GK
  2010-05-20 14:29 ` [PATCH] OMAP: McSPI: Fix Null pointer check Manjunatha GK
@ 2010-05-20 14:29 ` Manjunatha GK
  2010-05-20 14:29 ` [PATCH] OMAP: Fix Memory leak Manjunatha GK
  2010-05-20 15:11 ` [PATCH] OMAP2/3: Keypad: Fix memory leak Vimal Singh
  3 siblings, 0 replies; 7+ messages in thread
From: Manjunatha GK @ 2010-05-20 14:29 UTC (permalink / raw)
  To: linux-omap; +Cc: Satish Kumar, Tony Lindgren

From: Satish Kumar <satish.k@ti.com>

Fix Null pointer check for display pointer in omapfb_blank().

Signed-off-by: Satish Kumar <satish.k@ti.com>
Signed-off-by: Manjunatha GK <manjugk@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
---
 drivers/video/omap2/omapfb/omapfb-main.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/video/omap2/omapfb/omapfb-main.c b/drivers/video/omap2/omapfb/omapfb-main.c
index 4b4506d..63268cf 100644
--- a/drivers/video/omap2/omapfb/omapfb-main.c
+++ b/drivers/video/omap2/omapfb/omapfb-main.c
@@ -1217,6 +1217,11 @@ static int omapfb_blank(int blank, struct fb_info *fbi)
 	int do_update = 0;
 	int r = 0;
 
+	if (display == NULL) {
+		printk(KERN_ERR "omapfb_blank: fb2display returned NULL\n");
+		return -EINVAL;
+	}
+
 	omapfb_lock(fbdev);
 
 	switch (blank) {
-- 
1.7.0.4


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

* [PATCH] OMAP: Fix Memory leak
  2010-05-20 14:29 [PATCH] OMAP2/3: Keypad: Fix memory leak Manjunatha GK
  2010-05-20 14:29 ` [PATCH] OMAP: McSPI: Fix Null pointer check Manjunatha GK
  2010-05-20 14:29 ` [PATCH] OMAP: FB: " Manjunatha GK
@ 2010-05-20 14:29 ` Manjunatha GK
  2010-05-20 14:58   ` Vimal Singh
  2010-05-20 15:11 ` [PATCH] OMAP2/3: Keypad: Fix memory leak Vimal Singh
  3 siblings, 1 reply; 7+ messages in thread
From: Manjunatha GK @ 2010-05-20 14:29 UTC (permalink / raw)
  To: linux-omap; +Cc: Satish, Tony Lindgren

From: Satish <x0124230@ti.com>

The memory allocated for sgt structure is not freed on error
when sg_alloc_table is called in sg_alloc_table().

Signed-off-by: Satish Kumar <x0124230@ti.com>
Signed-off-by: Manjunatha GK <manjugk@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
---
 arch/arm/plat-omap/iovmm.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/arm/plat-omap/iovmm.c b/arch/arm/plat-omap/iovmm.c
index e43983b..8ce0de2 100644
--- a/arch/arm/plat-omap/iovmm.c
+++ b/arch/arm/plat-omap/iovmm.c
@@ -140,8 +140,10 @@ static struct sg_table *sgtable_alloc(const size_t bytes, u32 flags)
 		return ERR_PTR(-ENOMEM);
 
 	err = sg_alloc_table(sgt, nr_entries, GFP_KERNEL);
-	if (err)
+	if (err) {
+		kfree(sgt);
 		return ERR_PTR(err);
+	}
 
 	pr_debug("%s: sgt:%p(%d entries)\n", __func__, sgt, nr_entries);
 
-- 
1.7.0.4


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

* Re: [PATCH] OMAP: Fix Memory leak
  2010-05-20 14:29 ` [PATCH] OMAP: Fix Memory leak Manjunatha GK
@ 2010-05-20 14:58   ` Vimal Singh
  0 siblings, 0 replies; 7+ messages in thread
From: Vimal Singh @ 2010-05-20 14:58 UTC (permalink / raw)
  To: Manjunatha GK; +Cc: linux-omap, Satish, Tony Lindgren

On Thu, May 20, 2010 at 7:59 PM, Manjunatha GK <manjugk@ti.com> wrote:
> From: Satish <x0124230@ti.com>
>
> The memory allocated for sgt structure is not freed on error
> when sg_alloc_table is called in sg_alloc_table().

Typo mistake: correct "sg_alloc_table" to "sgtable_alloc" for second time.

-- 
Regards,
Vimal Singh

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

* Re: [PATCH] OMAP2/3: Keypad: Fix memory leak
  2010-05-20 14:29 [PATCH] OMAP2/3: Keypad: Fix memory leak Manjunatha GK
                   ` (2 preceding siblings ...)
  2010-05-20 14:29 ` [PATCH] OMAP: Fix Memory leak Manjunatha GK
@ 2010-05-20 15:11 ` Vimal Singh
  2010-05-20 15:16   ` Vimal Singh
  3 siblings, 1 reply; 7+ messages in thread
From: Vimal Singh @ 2010-05-20 15:11 UTC (permalink / raw)
  To: Manjunatha GK; +Cc: linux-omap, Damodar, Tony Lindgren

On Thu, May 20, 2010 at 7:59 PM, Manjunatha GK <manjugk@ti.com> wrote:
> From: Damodar <x0132156@ti.com>
>
> This patch corrects Possible memory leak of 'input' allocated
> through input_allocate_device and Suspicious dereference of pointer 'pdata'
> before NULL check
>
> Signed-off-by: Damodar Santhapuri <x0132156@ti.com>
> Signed-off-by: Manjunatha GK <manjugk@ti.com>
> Cc: Tony Lindgren <tony@atomide.com>
>
> ---
>  drivers/input/keyboard/twl4030_keypad.c |   21 +++++++++++++--------
>  1 files changed, 13 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c
> index 7aa59e0..aa13aec 100644
> --- a/drivers/input/keyboard/twl4030_keypad.c
> +++ b/drivers/input/keyboard/twl4030_keypad.c
> @@ -326,30 +326,34 @@ static int __devinit twl4030_kp_program(struct twl4030_keypad *kp)
>  */
>  static int __devinit twl4030_kp_probe(struct platform_device *pdev)
>  {
> -       struct twl4030_keypad_data *pdata = pdev->dev.platform_data;
> -       const struct matrix_keymap_data *keymap_data = pdata->keymap_data;
> +       struct twl4030_keypad_data *pdata;
> +       const struct matrix_keymap_data *keymap_data;
>        struct twl4030_keypad *kp;
>        struct input_dev *input;
>        u8 reg;
>        int error;
> -
> +       if (!pdev) {
> +               printk(KERN_ERR "Invalid platorm_device\n");
> +               return -EINVAL;
> +       }
> +       pdata = pdev->dev.platform_data;
>        if (!pdata || !pdata->rows || !pdata->cols ||
>            pdata->rows > TWL4030_MAX_ROWS || pdata->cols > TWL4030_MAX_COLS) {
>                dev_err(&pdev->dev, "Invalid platform_data\n");
>                return -EINVAL;
>        }
> -
> +       keymap_data = pdata->keymap_data;
>        kp = kzalloc(sizeof(*kp), GFP_KERNEL);
> +       if (!kp)
> +               return  -ENOMEM;
>        input = input_allocate_device();
> -       if (!kp || !input) {
> +       if (!input) {
>                error = -ENOMEM;
> -               goto err1;
> +               goto err0;

If I am not mistaking you should still goto 'err1', as
'input_register_device' is yet not called.

-- 
Regards,
Vimal Singh
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] OMAP2/3: Keypad: Fix memory leak
  2010-05-20 15:11 ` [PATCH] OMAP2/3: Keypad: Fix memory leak Vimal Singh
@ 2010-05-20 15:16   ` Vimal Singh
  0 siblings, 0 replies; 7+ messages in thread
From: Vimal Singh @ 2010-05-20 15:16 UTC (permalink / raw)
  To: Manjunatha GK; +Cc: linux-omap, Damodar, Tony Lindgren

On Thu, May 20, 2010 at 8:41 PM, Vimal Singh <vimal.newwork@gmail.com> wrote:
> On Thu, May 20, 2010 at 7:59 PM, Manjunatha GK <manjugk@ti.com> wrote:
>> From: Damodar <x0132156@ti.com>
>>
>> This patch corrects Possible memory leak of 'input' allocated
>> through input_allocate_device and Suspicious dereference of pointer 'pdata'
>> before NULL check
>>
>> Signed-off-by: Damodar Santhapuri <x0132156@ti.com>
>> Signed-off-by: Manjunatha GK <manjugk@ti.com>
>> Cc: Tony Lindgren <tony@atomide.com>
>>
>> ---
>>  drivers/input/keyboard/twl4030_keypad.c |   21 +++++++++++++--------
>>  1 files changed, 13 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/input/keyboard/twl4030_keypad.c b/drivers/input/keyboard/twl4030_keypad.c
>> index 7aa59e0..aa13aec 100644
>> --- a/drivers/input/keyboard/twl4030_keypad.c
>> +++ b/drivers/input/keyboard/twl4030_keypad.c
>> @@ -326,30 +326,34 @@ static int __devinit twl4030_kp_program(struct twl4030_keypad *kp)
>>  */
>>  static int __devinit twl4030_kp_probe(struct platform_device *pdev)
>>  {
>> -       struct twl4030_keypad_data *pdata = pdev->dev.platform_data;
>> -       const struct matrix_keymap_data *keymap_data = pdata->keymap_data;
>> +       struct twl4030_keypad_data *pdata;
>> +       const struct matrix_keymap_data *keymap_data;
>>        struct twl4030_keypad *kp;
>>        struct input_dev *input;
>>        u8 reg;
>>        int error;
>> -
>> +       if (!pdev) {
>> +               printk(KERN_ERR "Invalid platorm_device\n");
>> +               return -EINVAL;
>> +       }
>> +       pdata = pdev->dev.platform_data;
>>        if (!pdata || !pdata->rows || !pdata->cols ||
>>            pdata->rows > TWL4030_MAX_ROWS || pdata->cols > TWL4030_MAX_COLS) {
>>                dev_err(&pdev->dev, "Invalid platform_data\n");
>>                return -EINVAL;
>>        }
>> -
>> +       keymap_data = pdata->keymap_data;
>>        kp = kzalloc(sizeof(*kp), GFP_KERNEL);
>> +       if (!kp)
>> +               return  -ENOMEM;
>>        input = input_allocate_device();
>> -       if (!kp || !input) {
>> +       if (!input) {
>>                error = -ENOMEM;
>> -               goto err1;
>> +               goto err0;
>
> If I am not mistaking you should still goto 'err1', as
> 'input_register_device' is yet not called.

Sorry, my ignorance that device is yet not allocated.

-- 
Regards,
Vimal Singh
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2010-05-20 15:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-20 14:29 [PATCH] OMAP2/3: Keypad: Fix memory leak Manjunatha GK
2010-05-20 14:29 ` [PATCH] OMAP: McSPI: Fix Null pointer check Manjunatha GK
2010-05-20 14:29 ` [PATCH] OMAP: FB: " Manjunatha GK
2010-05-20 14:29 ` [PATCH] OMAP: Fix Memory leak Manjunatha GK
2010-05-20 14:58   ` Vimal Singh
2010-05-20 15:11 ` [PATCH] OMAP2/3: Keypad: Fix memory leak Vimal Singh
2010-05-20 15:16   ` Vimal Singh

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).