platform/mellanox: mlxreg-hotplug: Fix uninitialized variable

"Linux Kernel Mailing List" <[email protected]> Sat, 10 Feb 2018 22:00:25 +0000 (UTC)
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/b81e830c9ad041aba81b495d9386dc31aed3f1e6
Commit:     b81e830c9ad041aba81b495d9386dc31aed3f1e6
Parent:     9a7c551ba7aae3648473179f234e960cfd46eaf4
Refname:    refs/heads/master
Author:     Geert Uytterhoeven <[email protected]>
AuthorDate: Wed Feb 7 10:12:04 2018 +0100
Committer:  Darren Hart (VMware) <[email protected]>
CommitDate: Thu Feb 8 17:43:37 2018 -0800

    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")
    Signed-off-by: Geert Uytterhoeven <[email protected]>
    Acked-by: Vadim Pasternak <[email protected]>
    Signed-off-by: Darren Hart (VMware) <[email protected]>
---
 drivers/platform/mellanox/mlxreg-hotplug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c
index 0dfa1ca0d05b..313cf8ad77bf 100644
--- a/drivers/platform/mellanox/mlxreg-hotplug.c
+++ b/drivers/platform/mellanox/mlxreg-hotplug.c
@@ -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. */
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html