Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1168562 > unrolled thread

[PATCH 3/4] extcon: palmas: Fix NULL pointer error

Started byChanwoo Choi <cwchoi00@gmail.com>
First post2015-06-19 08:50 +0200
Last post2015-06-22 03:00 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 3/4] extcon: palmas: Fix NULL pointer error Chanwoo Choi <cwchoi00@gmail.com> - 2015-06-19 08:50 +0200
    Re: [PATCH 3/4] extcon: palmas: Fix NULL pointer error Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2015-06-22 02:50 +0200
      Re: [PATCH 3/4] extcon: palmas: Fix NULL pointer error Chanwoo Choi <cwchoi00@gmail.com> - 2015-06-22 03:00 +0200

#1168562 — [PATCH 3/4] extcon: palmas: Fix NULL pointer error

FromChanwoo Choi <cwchoi00@gmail.com>
Date2015-06-19 08:50 +0200
Subject[PATCH 3/4] extcon: palmas: Fix NULL pointer error
Message-ID<pCYhI-82R-9@gated-at.bofh.it>
This patch fixes NULL pointer error by removing the unneeded kfree() call
of edev->name because extcon-palmas no longer allocate the memory for edev->name.

Fixes: d71aadda19f8 ("extcon: Remove the optional name of extcon device")
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
---
 drivers/extcon/extcon-palmas.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
index 080d5cc..4e7335f 100644
--- a/drivers/extcon/extcon-palmas.c
+++ b/drivers/extcon/extcon-palmas.c
@@ -200,7 +200,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
 	status = devm_extcon_dev_register(&pdev->dev, palmas_usb->edev);
 	if (status) {
 		dev_err(&pdev->dev, "failed to register extcon device\n");
-		kfree(palmas_usb->edev->name);
 		return status;
 	}
 
@@ -214,7 +213,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
 		if (status < 0) {
 			dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
 					palmas_usb->id_irq, status);
-			kfree(palmas_usb->edev->name);
 			return status;
 		}
 	}
@@ -229,7 +227,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
 		if (status < 0) {
 			dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
 					palmas_usb->vbus_irq, status);
-			kfree(palmas_usb->edev->name);
 			return status;
 		}
 	}
@@ -241,10 +238,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
 
 static int palmas_usb_remove(struct platform_device *pdev)
 {
-	struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
-
-	kfree(palmas_usb->edev->name);
-
 	return 0;
 }
 
-- 
2.2.0.GIT

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1169669

FromKrzysztof Kozlowski <k.kozlowski@samsung.com>
Date2015-06-22 02:50 +0200
Message-ID<pDY5X-4JI-3@gated-at.bofh.it>
In reply to#1168562
2015-06-19 15:48 GMT+09:00 Chanwoo Choi <cwchoi00@gmail.com>:
> This patch fixes NULL pointer error by removing the unneeded kfree() call
> of edev->name because extcon-palmas no longer allocate the memory for edev->name.

So the kfree() was executed on pointer returned by "dev_name(edev->dev.parent)"?



> Fixes: d71aadda19f8 ("extcon: Remove the optional name of extcon device")
> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
> ---
>  drivers/extcon/extcon-palmas.c | 7 -------
>  1 file changed, 7 deletions(-)
>
> diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
> index 080d5cc..4e7335f 100644
> --- a/drivers/extcon/extcon-palmas.c
> +++ b/drivers/extcon/extcon-palmas.c
> @@ -200,7 +200,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
>         status = devm_extcon_dev_register(&pdev->dev, palmas_usb->edev);
>         if (status) {
>                 dev_err(&pdev->dev, "failed to register extcon device\n");
> -               kfree(palmas_usb->edev->name);
>                 return status;
>         }
>
> @@ -214,7 +213,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
>                 if (status < 0) {
>                         dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
>                                         palmas_usb->id_irq, status);
> -                       kfree(palmas_usb->edev->name);
>                         return status;
>                 }
>         }
> @@ -229,7 +227,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
>                 if (status < 0) {
>                         dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
>                                         palmas_usb->vbus_irq, status);
> -                       kfree(palmas_usb->edev->name);
>                         return status;
>                 }
>         }
> @@ -241,10 +238,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
>
>  static int palmas_usb_remove(struct platform_device *pdev)
>  {
> -       struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
> -
> -       kfree(palmas_usb->edev->name);
> -
>         return 0;
>  }

The remove function is now no-op so I think you can remove it. The
platform driver code executes it only if it is non-NULL.

Best regards,
Krzysztof
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1169670

FromChanwoo Choi <cwchoi00@gmail.com>
Date2015-06-22 03:00 +0200
Message-ID<pDYfD-4UV-1@gated-at.bofh.it>
In reply to#1169669
On Mon, Jun 22, 2015 at 9:45 AM, Krzysztof Kozlowski
<k.kozlowski@samsung.com> wrote:
> 2015-06-19 15:48 GMT+09:00 Chanwoo Choi <cwchoi00@gmail.com>:
>> This patch fixes NULL pointer error by removing the unneeded kfree() call
>> of edev->name because extcon-palmas no longer allocate the memory for edev->name.
>
> So the kfree() was executed on pointer returned by "dev_name(edev->dev.parent)"?
>

Right.

>
>> Fixes: d71aadda19f8 ("extcon: Remove the optional name of extcon device")
>> Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
>> ---
>>  drivers/extcon/extcon-palmas.c | 7 -------
>>  1 file changed, 7 deletions(-)
>>
>> diff --git a/drivers/extcon/extcon-palmas.c b/drivers/extcon/extcon-palmas.c
>> index 080d5cc..4e7335f 100644
>> --- a/drivers/extcon/extcon-palmas.c
>> +++ b/drivers/extcon/extcon-palmas.c
>> @@ -200,7 +200,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
>>         status = devm_extcon_dev_register(&pdev->dev, palmas_usb->edev);
>>         if (status) {
>>                 dev_err(&pdev->dev, "failed to register extcon device\n");
>> -               kfree(palmas_usb->edev->name);
>>                 return status;
>>         }
>>
>> @@ -214,7 +213,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
>>                 if (status < 0) {
>>                         dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
>>                                         palmas_usb->id_irq, status);
>> -                       kfree(palmas_usb->edev->name);
>>                         return status;
>>                 }
>>         }
>> @@ -229,7 +227,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
>>                 if (status < 0) {
>>                         dev_err(&pdev->dev, "can't get IRQ %d, err %d\n",
>>                                         palmas_usb->vbus_irq, status);
>> -                       kfree(palmas_usb->edev->name);
>>                         return status;
>>                 }
>>         }
>> @@ -241,10 +238,6 @@ static int palmas_usb_probe(struct platform_device *pdev)
>>
>>  static int palmas_usb_remove(struct platform_device *pdev)
>>  {
>> -       struct palmas_usb *palmas_usb = platform_get_drvdata(pdev);
>> -
>> -       kfree(palmas_usb->edev->name);
>> -
>>         return 0;
>>  }
>
> The remove function is now no-op so I think you can remove it. The
> platform driver code executes it only if it is non-NULL.

OK.

Thanks,
Chanwoo Choi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web