linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] power: supply: charger-manager: 1 fix and 2 minor clean-ups
@ 2017-08-06 22:37 Christophe JAILLET
  2017-08-06 22:37 ` [PATCH 1/3] power: supply: charger-manager: Fix a NULL pointer dereference in 'charger_manager_probe()' Christophe JAILLET
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Christophe JAILLET @ 2017-08-06 22:37 UTC (permalink / raw)
  To: sre; +Cc: linux-pm, linux-kernel, kernel-janitors, Christophe JAILLET

This patch series improves 'charger_manager_probe()'. The first patch is
about a missing memory allocation failure test.
The 2 others are just things spotted in this function:
   - a comment that is no more up to date
   - a style issue (which saves 1 line)

Christophe JAILLET (3):
  power: supply: charger-manager: Fix a NULL pointer dereference in
    'charger_manager_probe()'
  power: supply: charger-manager: Fix a comment
  power: supply: charger-manager: Slighly simplify code

 drivers/power/supply/charger-manager.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

-- 
2.11.0

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

* [PATCH 1/3] power: supply: charger-manager: Fix a NULL pointer dereference in 'charger_manager_probe()'
  2017-08-06 22:37 [PATCH 0/3] power: supply: charger-manager: 1 fix and 2 minor clean-ups Christophe JAILLET
@ 2017-08-06 22:37 ` Christophe JAILLET
  2017-08-06 22:37 ` [PATCH 2/3] power: supply: charger-manager: Fix a comment Christophe JAILLET
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Christophe JAILLET @ 2017-08-06 22:37 UTC (permalink / raw)
  To: sre; +Cc: linux-pm, linux-kernel, kernel-janitors, Christophe JAILLET

'devm_kzalloc()' can return NULL. Return -ENOMEM in this case in order to
avoid a NULL pointer dereference later on.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/power/supply/charger-manager.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c
index adc3761831e1..52a49857e20f 100644
--- a/drivers/power/supply/charger-manager.c
+++ b/drivers/power/supply/charger-manager.c
@@ -1645,6 +1645,8 @@ static int charger_manager_probe(struct platform_device *pdev)
 	/* Initialize alarm timer */
 	if (alarmtimer_get_rtcdev()) {
 		cm_timer = devm_kzalloc(cm->dev, sizeof(*cm_timer), GFP_KERNEL);
+		if (!cm_timer)
+			return -ENOMEM;
 		alarm_init(cm_timer, ALARM_BOOTTIME, cm_timer_func);
 	}
 
-- 
2.11.0

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

* [PATCH 2/3] power: supply: charger-manager: Fix a comment
  2017-08-06 22:37 [PATCH 0/3] power: supply: charger-manager: 1 fix and 2 minor clean-ups Christophe JAILLET
  2017-08-06 22:37 ` [PATCH 1/3] power: supply: charger-manager: Fix a NULL pointer dereference in 'charger_manager_probe()' Christophe JAILLET
@ 2017-08-06 22:37 ` Christophe JAILLET
  2017-08-06 22:37 ` [PATCH 3/3] power: supply: charger-manager: Slighly simplify code Christophe JAILLET
  2017-08-12 18:03 ` [PATCH 0/3] power: supply: charger-manager: 1 fix and 2 minor clean-ups Sebastian Reichel
  3 siblings, 0 replies; 5+ messages in thread
From: Christophe JAILLET @ 2017-08-06 22:37 UTC (permalink / raw)
  To: sre; +Cc: linux-pm, linux-kernel, kernel-janitors, Christophe JAILLET

Update a comment which is no more up to date since commit
2ed9e9b653095.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/power/supply/charger-manager.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c
index 52a49857e20f..83c08c8e2c32 100644
--- a/drivers/power/supply/charger-manager.c
+++ b/drivers/power/supply/charger-manager.c
@@ -1651,8 +1651,8 @@ static int charger_manager_probe(struct platform_device *pdev)
 	}
 
 	/*
-	 * The following two do not need to be errors.
-	 * Users may intentionally ignore those two features.
+	 * Some of the following do not need to be errors.
+	 * Users may intentionally ignore those features.
 	 */
 	if (desc->fullbatt_uV == 0) {
 		dev_info(&pdev->dev, "Ignoring full-battery voltage threshold as it is not supplied\n");
-- 
2.11.0

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

* [PATCH 3/3] power: supply: charger-manager: Slighly simplify code
  2017-08-06 22:37 [PATCH 0/3] power: supply: charger-manager: 1 fix and 2 minor clean-ups Christophe JAILLET
  2017-08-06 22:37 ` [PATCH 1/3] power: supply: charger-manager: Fix a NULL pointer dereference in 'charger_manager_probe()' Christophe JAILLET
  2017-08-06 22:37 ` [PATCH 2/3] power: supply: charger-manager: Fix a comment Christophe JAILLET
@ 2017-08-06 22:37 ` Christophe JAILLET
  2017-08-12 18:03 ` [PATCH 0/3] power: supply: charger-manager: 1 fix and 2 minor clean-ups Sebastian Reichel
  3 siblings, 0 replies; 5+ messages in thread
From: Christophe JAILLET @ 2017-08-06 22:37 UTC (permalink / raw)
  To: sre; +Cc: linux-pm, linux-kernel, kernel-janitors, Christophe JAILLET

Use 'sizeof(*var)' instead of the equivalent 'sizeof(data structure type)'
because it is less verbose.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/power/supply/charger-manager.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c
index 83c08c8e2c32..6502fa7c2106 100644
--- a/drivers/power/supply/charger-manager.c
+++ b/drivers/power/supply/charger-manager.c
@@ -1632,8 +1632,7 @@ static int charger_manager_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	cm = devm_kzalloc(&pdev->dev,
-			sizeof(struct charger_manager),	GFP_KERNEL);
+	cm = devm_kzalloc(&pdev->dev, sizeof(*cm), GFP_KERNEL);
 	if (!cm)
 		return -ENOMEM;
 
-- 
2.11.0

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

* Re: [PATCH 0/3] power: supply: charger-manager: 1 fix and 2 minor clean-ups
  2017-08-06 22:37 [PATCH 0/3] power: supply: charger-manager: 1 fix and 2 minor clean-ups Christophe JAILLET
                   ` (2 preceding siblings ...)
  2017-08-06 22:37 ` [PATCH 3/3] power: supply: charger-manager: Slighly simplify code Christophe JAILLET
@ 2017-08-12 18:03 ` Sebastian Reichel
  3 siblings, 0 replies; 5+ messages in thread
From: Sebastian Reichel @ 2017-08-12 18:03 UTC (permalink / raw)
  To: Christophe JAILLET; +Cc: linux-pm, linux-kernel, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 742 bytes --]

Hi,

On Mon, Aug 07, 2017 at 12:37:54AM +0200, Christophe JAILLET wrote:
> This patch series improves 'charger_manager_probe()'. The first patch is
> about a missing memory allocation failure test.
> The 2 others are just things spotted in this function:
>    - a comment that is no more up to date
>    - a style issue (which saves 1 line)
> 
> Christophe JAILLET (3):
>   power: supply: charger-manager: Fix a NULL pointer dereference in
>     'charger_manager_probe()'
>   power: supply: charger-manager: Fix a comment
>   power: supply: charger-manager: Slighly simplify code
> 
>  drivers/power/supply/charger-manager.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)

Thanks, queued.

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2017-08-12 18:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-06 22:37 [PATCH 0/3] power: supply: charger-manager: 1 fix and 2 minor clean-ups Christophe JAILLET
2017-08-06 22:37 ` [PATCH 1/3] power: supply: charger-manager: Fix a NULL pointer dereference in 'charger_manager_probe()' Christophe JAILLET
2017-08-06 22:37 ` [PATCH 2/3] power: supply: charger-manager: Fix a comment Christophe JAILLET
2017-08-06 22:37 ` [PATCH 3/3] power: supply: charger-manager: Slighly simplify code Christophe JAILLET
2017-08-12 18:03 ` [PATCH 0/3] power: supply: charger-manager: 1 fix and 2 minor clean-ups Sebastian Reichel

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