linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] power: charger-manager: regulator_get() never returns NULL.
@ 2013-06-25  5:02 Jonghwa Lee
  2013-06-25  5:02 ` [PATCH 2/2] power: charger-manager: Fix a bug when it unregisters notifier block of extcon Jonghwa Lee
  2013-06-25  5:07 ` [PATCH 1/2] power: charger-manager: regulator_get() never returns NULL Sachin Kamat
  0 siblings, 2 replies; 6+ messages in thread
From: Jonghwa Lee @ 2013-06-25  5:02 UTC (permalink / raw)
  To: anton.vorontsov; +Cc: linux-kernel, Jonghwa Lee, Myungjoo Ham

This patch fixes return value checking of regulator_get() in charger-manager
driver. The API, regulator_get(), returns ERR_PTR() when it fails to get
regulator with given name, not NULL.

Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
---
 drivers/power/charger-manager.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
index ba42029..7d1bcde 100644
--- a/drivers/power/charger-manager.c
+++ b/drivers/power/charger-manager.c
@@ -1239,7 +1239,7 @@ static int charger_manager_register_extcon(struct charger_manager *cm)
 
 		charger->consumer = regulator_get(cm->dev,
 					charger->regulator_name);
-		if (charger->consumer == NULL) {
+		if (IS_ERR(charger->consumer)) {
 			dev_err(cm->dev, "Cannot find charger(%s)\n",
 				charger->regulator_name);
 			ret = -EINVAL;
-- 
1.7.9.5


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

* [PATCH 2/2] power: charger-manager: Fix a bug when it unregisters notifier block of extcon.
  2013-06-25  5:02 [PATCH 1/2] power: charger-manager: regulator_get() never returns NULL Jonghwa Lee
@ 2013-06-25  5:02 ` Jonghwa Lee
       [not found]   ` <CAGTfZH1q8b0VyDsSsFa7DooHbLN46PTYofCRXCYRThnuNRjCwg@mail.gmail.com>
  2013-06-25  5:07 ` [PATCH 1/2] power: charger-manager: regulator_get() never returns NULL Sachin Kamat
  1 sibling, 1 reply; 6+ messages in thread
From: Jonghwa Lee @ 2013-06-25  5:02 UTC (permalink / raw)
  To: anton.vorontsov; +Cc: linux-kernel, Jonghwa Lee, Myungjoo Ham

This patch prevents NULL pointer error cauesed by unregistering unregistered
exton notifier block. At the probing time of charger manager, it tries to
remove extcon notifier block when it fails to initialize them. It has to be
applied for only registered one. Otherwise, it'd make kernel panic. To make it
work right, it checks extcon_specific_cable_nb's extcon_dev node. If extcon
cable notifier block was registered successfully, it has proper extcon_dev
pointer if not so it has NULL pointer.

Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
---
 drivers/power/charger-manager.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
index 7d1bcde..c55a7dc 100644
--- a/drivers/power/charger-manager.c
+++ b/drivers/power/charger-manager.c
@@ -1666,7 +1666,9 @@ err_reg_extcon:
 		charger = &desc->charger_regulators[i];
 		for (j = 0; j < charger->num_cables; j++) {
 			struct charger_cable *cable = &charger->cables[j];
-			extcon_unregister_interest(&cable->extcon_dev);
+			/* Remove notifier block if only edev exists */
+			if (cable->extcon_dev.edev)
+				extcon_unregister_interest(&cable->extcon_dev);
 		}
 
 		regulator_put(desc->charger_regulators[i].consumer);
-- 
1.7.9.5


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

* Re: [PATCH 1/2] power: charger-manager: regulator_get() never returns NULL.
  2013-06-25  5:02 [PATCH 1/2] power: charger-manager: regulator_get() never returns NULL Jonghwa Lee
  2013-06-25  5:02 ` [PATCH 2/2] power: charger-manager: Fix a bug when it unregisters notifier block of extcon Jonghwa Lee
@ 2013-06-25  5:07 ` Sachin Kamat
  2013-06-25  5:09   ` jonghwa3.lee
  1 sibling, 1 reply; 6+ messages in thread
From: Sachin Kamat @ 2013-06-25  5:07 UTC (permalink / raw)
  To: Jonghwa Lee; +Cc: anton.vorontsov, linux-kernel, Myungjoo Ham

On 25 June 2013 10:32, Jonghwa Lee <jonghwa3.lee@samsung.com> wrote:
> This patch fixes return value checking of regulator_get() in charger-manager
> driver. The API, regulator_get(), returns ERR_PTR() when it fails to get
> regulator with given name, not NULL.
>
> Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
> ---
>  drivers/power/charger-manager.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
> index ba42029..7d1bcde 100644
> --- a/drivers/power/charger-manager.c
> +++ b/drivers/power/charger-manager.c
> @@ -1239,7 +1239,7 @@ static int charger_manager_register_extcon(struct charger_manager *cm)
>
>                 charger->consumer = regulator_get(cm->dev,
>                                         charger->regulator_name);
> -               if (charger->consumer == NULL) {
> +               if (IS_ERR(charger->consumer)) {
>                         dev_err(cm->dev, "Cannot find charger(%s)\n",
>                                 charger->regulator_name);
>                         ret = -EINVAL;

 You can as well make this ret = PTR_ERR(charger->consumer).

---
With warm regards,
Sachin

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

* Re: [PATCH 1/2] power: charger-manager: regulator_get() never returns NULL.
  2013-06-25  5:07 ` [PATCH 1/2] power: charger-manager: regulator_get() never returns NULL Sachin Kamat
@ 2013-06-25  5:09   ` jonghwa3.lee
  0 siblings, 0 replies; 6+ messages in thread
From: jonghwa3.lee @ 2013-06-25  5:09 UTC (permalink / raw)
  To: Sachin Kamat; +Cc: anton.vorontsov, linux-kernel, Myungjoo Ham

On 2013년 06월 25일 14:07, Sachin Kamat wrote:

> On 25 June 2013 10:32, Jonghwa Lee <jonghwa3.lee@samsung.com> wrote:
>> This patch fixes return value checking of regulator_get() in charger-manager
>> driver. The API, regulator_get(), returns ERR_PTR() when it fails to get
>> regulator with given name, not NULL.
>>
>> Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
>> Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com>
>> ---
>>  drivers/power/charger-manager.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
>> index ba42029..7d1bcde 100644
>> --- a/drivers/power/charger-manager.c
>> +++ b/drivers/power/charger-manager.c
>> @@ -1239,7 +1239,7 @@ static int charger_manager_register_extcon(struct charger_manager *cm)
>>
>>                 charger->consumer = regulator_get(cm->dev,
>>                                         charger->regulator_name);
>> -               if (charger->consumer == NULL) {
>> +               if (IS_ERR(charger->consumer)) {
>>                         dev_err(cm->dev, "Cannot find charger(%s)\n",
>>                                 charger->regulator_name);
>>                         ret = -EINVAL;
> 
>  You can as well make this ret = PTR_ERR(charger->consumer).


Yes, I'll fix it.

Thanks,
Jonghwa

> 
> ---
> With warm regards,
> Sachin
> 



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

* Re: [PATCH 2/2] power: charger-manager: Fix a bug when it unregisters notifier block of extcon.
       [not found]   ` <CAGTfZH1q8b0VyDsSsFa7DooHbLN46PTYofCRXCYRThnuNRjCwg@mail.gmail.com>
@ 2013-06-26  1:19     ` jonghwa3.lee
  2013-06-26  1:22       ` Chanwoo Choi
  0 siblings, 1 reply; 6+ messages in thread
From: jonghwa3.lee @ 2013-06-26  1:19 UTC (permalink / raw)
  To: Chanwoo Choi; +Cc: Anton Vorontsov, linux-kernel, Myungjoo Ham

Hi,
On 2013년 06월 25일 22:34, Chanwoo Choi wrote:

> On Tue, Jun 25, 2013 at 2:02 PM, Jonghwa Lee <jonghwa3.lee@samsung.com
> <mailto:jonghwa3.lee@samsung.com>> wrote:
> 
>     This patch prevents NULL pointer error cauesed by unregistering unregistered
>     exton notifier block. At the probing time of charger manager, it tries to
>     remove extcon notifier block when it fails to initialize them. It has to be
>     applied for only registered one. Otherwise, it'd make kernel panic. To make it
>     work right, it checks extcon_specific_cable_nb's extcon_dev node. If extcon
>     cable notifier block was registered successfully, it has proper extcon_dev
>     pointer if not so it has NULL pointer.
> 
>     Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com
>     <mailto:jonghwa3.lee@samsung.com>>
>     Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com
>     <mailto:myungjoo.ham@samsung.com>>
>     ---
>      drivers/power/charger-manager.c |    4 +++-
>      1 file changed, 3 insertions(+), 1 deletion(-)
> 
>     diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
>     index 7d1bcde..c55a7dc 100644
>     --- a/drivers/power/charger-manager.c
>     +++ b/drivers/power/charger-manager.c
>     @@ -1666,7 +1666,9 @@ err_reg_extcon:
>                     charger = &desc->charger_regulators[i];
>                     for (j = 0; j < charger->num_cables; j++) {
>                             struct charger_cable *cable = &charger->cables[j];
>     -                       extcon_unregister_interest(&cable->extcon_dev);
>     +                       /* Remove notifier block if only edev exists */
>     +                       if (cable->extcon_dev.edev)
>     +                               extcon_unregister_interest(&cable->extcon_dev);
>                     }
> 
>                     regulator_put(desc->charger_regulators[i].consumer);
>     --
>     1.7.9.5
> 
> 
> The charger-manager.c call extcon_unregister_interest() in
> charger_manager_remove() function.
> So, you should to fix it on charger_manager_remove() to remove NULL pointer error.
> 


When .remove() callback function is called, there is no unregistered cable
notifier block. Because all extcon notifier block would be registered at probing
time, and if it is failed the probing can't be achieved. So I think it doesn't
need to fix .remove() callback function as like above.

Thank you for reviewing.

Best regards,
Jonghwa.


> Acked-by: Chanwoo Choi <cw00.choi@samsung.com <mailto:cw00.choi@samsung.com>>
> 
> Thanks,
> Chanwoo Choi
>  



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

* Re: [PATCH 2/2] power: charger-manager: Fix a bug when it unregisters notifier block of extcon.
  2013-06-26  1:19     ` jonghwa3.lee
@ 2013-06-26  1:22       ` Chanwoo Choi
  0 siblings, 0 replies; 6+ messages in thread
From: Chanwoo Choi @ 2013-06-26  1:22 UTC (permalink / raw)
  To: jonghwa3.lee; +Cc: Anton Vorontsov, linux-kernel, Myungjoo Ham

On 06/26/2013 10:19 AM, jonghwa3.lee@samsung.com wrote:
> Hi,
> On 2013년 06월 25일 22:34, Chanwoo Choi wrote:
> 
>> On Tue, Jun 25, 2013 at 2:02 PM, Jonghwa Lee <jonghwa3.lee@samsung.com
>> <mailto:jonghwa3.lee@samsung.com>> wrote:
>>
>>     This patch prevents NULL pointer error cauesed by unregistering unregistered
>>     exton notifier block. At the probing time of charger manager, it tries to
>>     remove extcon notifier block when it fails to initialize them. It has to be
>>     applied for only registered one. Otherwise, it'd make kernel panic. To make it
>>     work right, it checks extcon_specific_cable_nb's extcon_dev node. If extcon
>>     cable notifier block was registered successfully, it has proper extcon_dev
>>     pointer if not so it has NULL pointer.
>>
>>     Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com
>>     <mailto:jonghwa3.lee@samsung.com>>
>>     Signed-off-by: Myungjoo Ham <myungjoo.ham@samsung.com
>>     <mailto:myungjoo.ham@samsung.com>>
>>     ---
>>      drivers/power/charger-manager.c |    4 +++-
>>      1 file changed, 3 insertions(+), 1 deletion(-)
>>
>>     diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
>>     index 7d1bcde..c55a7dc 100644
>>     --- a/drivers/power/charger-manager.c
>>     +++ b/drivers/power/charger-manager.c
>>     @@ -1666,7 +1666,9 @@ err_reg_extcon:
>>                     charger = &desc->charger_regulators[i];
>>                     for (j = 0; j < charger->num_cables; j++) {
>>                             struct charger_cable *cable = &charger->cables[j];
>>     -                       extcon_unregister_interest(&cable->extcon_dev);
>>     +                       /* Remove notifier block if only edev exists */
>>     +                       if (cable->extcon_dev.edev)
>>     +                               extcon_unregister_interest(&cable->extcon_dev);
>>                     }
>>
>>                     regulator_put(desc->charger_regulators[i].consumer);
>>     --
>>     1.7.9.5
>>
>>
>> The charger-manager.c call extcon_unregister_interest() in
>> charger_manager_remove() function.
>> So, you should to fix it on charger_manager_remove() to remove NULL pointer error.
>>
> 
> 
> When .remove() callback function is called, there is no unregistered cable
> notifier block. Because all extcon notifier block would be registered at probing
> time, and if it is failed the probing can't be achieved. So I think it doesn't
> need to fix .remove() callback function as like above.
> 
> Thank you for reviewing.
> 
> Best regards,
> Jonghwa.
> 
> 
>> Acked-by: Chanwoo Choi <cw00.choi@samsung.com <mailto:cw00.choi@samsung.com>>
>>
>> Thanks,
>> Chanwoo Choi
>>  
> 

OK, I agree your opinion.

Acked-by: Chanwoo Choi <cw00.choi@samsung.com>

Thanks,
Chanwoo Choi


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

end of thread, other threads:[~2013-06-26  1:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-25  5:02 [PATCH 1/2] power: charger-manager: regulator_get() never returns NULL Jonghwa Lee
2013-06-25  5:02 ` [PATCH 2/2] power: charger-manager: Fix a bug when it unregisters notifier block of extcon Jonghwa Lee
     [not found]   ` <CAGTfZH1q8b0VyDsSsFa7DooHbLN46PTYofCRXCYRThnuNRjCwg@mail.gmail.com>
2013-06-26  1:19     ` jonghwa3.lee
2013-06-26  1:22       ` Chanwoo Choi
2013-06-25  5:07 ` [PATCH 1/2] power: charger-manager: regulator_get() never returns NULL Sachin Kamat
2013-06-25  5:09   ` jonghwa3.lee

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