Skip to contentSkip to conversation

platform/mellanox: mlxreg-hotplug: Fix uninitialized variable

PATCH In review Geert Uytterhoeven 2 participants 2 messages Feb 7, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 platform/mellanox: mlxreg-hotplug: Fix uninitialized variable

With gcc-4.1.2:

drivers/platform/mellanox/mlxreg-hotplug.c: In function ‘mlxreg_hotplug_health_work_helper’:
drivers/platform/mellanox/mlxreg-hotplug.c:347: warning: ‘ret’ is used uninitialized in this function

Indeed, if mlxreg_core_item.count is zero, ret is used uninitialized.

While this is unlikely to happen (it is set to ARRAY_SIZE(...) in x86 board files), this is done in another source file, so fix this by preinitializing ret to zero.

Fixes c6acad68eb2dbffd ("platform/mellanox: mlxreg-hotplug: Modify to use a regmap interface")
---
 drivers/platform/mellanox/mlxreg-hotplug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/mellanox/mlxreg-hotplug.c +1 -1
index 0dfa1ca0d05b0217..313cf8ad77bf68ce 100644
@@ -300,7 +300,7 @@ mlxreg_hotplug_health_work_helper(struct mlxreg_hotplug_priv_data *priv,
 {
 	struct mlxreg_core_data *data = item->data;
 	u32 regval;
-	int i, ret;
+	int i, ret = 0;
 
 	for (i = 0; i < item->count; i++, data++) {
 		/* Mask event. */
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#1 lore raw
Quoted 18 lines

-----Original Message-----
From: Geert Uytterhoeven [mailto:[email protected]]
Sent: Wednesday, February 07, 2018 11:12 AM
To: Andy Shevchenko <[email protected]>; Darren Hart <[email protected]>; Vadim Pasternak <[email protected]>
Cc: Arnd Bergmann <[email protected]>; [email protected]; [email protected]; Geert Uytterhoeven <[email protected]>
Subject: [PATCH] platform/mellanox: mlxreg-hotplug: Fix uninitialized variable

With gcc-4.1.2:

drivers/platform/mellanox/mlxreg-hotplug.c: In function
‘mlxreg_hotplug_health_work_helper’:
drivers/platform/mellanox/mlxreg-hotplug.c:347: warning: ‘ret’ is used
uninitialized in this function

Quoted 8 lines

Indeed, if mlxreg_core_item.count is zero, ret is used uninitialized.

While this is unlikely to happen (it is set to ARRAY_SIZE(...) in x86 board files), this is done in another source file, so fix this by preinitializing ret to zero.

Fixes c6acad68eb2dbffd ("platform/mellanox: mlxreg-hotplug: Modify to use a

regmap interface")

Quoted 20 lines
---
 drivers/platform/mellanox/mlxreg-hotplug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/mellanox/mlxreg-hotplug.c +1 -2
index 0dfa1ca0d05b0217..313cf8ad77bf68ce 100644
@@ -300,7 +300,7 @@ mlxreg_hotplug_health_work_helper(struct
 mlxreg_hotplug_priv_data *priv,  {
 	struct mlxreg_core_data *data = item->data;
 	u32 regval;
-	int i, ret;
+	int i, ret = 0;
 
 	for (i = 0; i < item->count; i++, data++) {
 		/* Mask event. */
--

2.7.4