lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1341347661-26567-1-git-send-email-swarren@wwwdotorg.org>
Date:	Tue,  3 Jul 2012 14:34:21 -0600
From:	Stephen Warren <swarren@...dotorg.org>
To:	Thierry Reding <thierry.reding@...onic-design.de>
Cc:	linux-kernel@...r.kernel.org, Stephen Warren <swarren@...dia.com>
Subject: [PATCH] pwm: fix used-uninitialized warning in pwm_get()

From: Stephen Warren <swarren@...dia.com>

This fixes:
drivers/pwm/core.c: In function 'pwm_get':
drivers/pwm/core.c:534:15: warning: 'index' may be used uninitialized in this function

The addition to the if condition at end of the function isn't strictly
necessary to solve the warning, but does make it more obvious that the
initialization of "index" to a dummy value isn't just hiding the
problem.

Signed-off-by: Stephen Warren <swarren@...dia.com>
---
 drivers/pwm/core.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index dbab530..2b401c0 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -531,7 +531,7 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
 	struct pwm_chip *chip = NULL;
 	unsigned int best = 0;
 	struct pwm_lookup *p;
-	unsigned int index;
+	unsigned int index = -1;
 	unsigned int match;
 
 	/* look up via DT first */
@@ -588,7 +588,7 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)
 		}
 	}
 
-	if (chip)
+	if (chip && index != -1)
 		pwm = pwm_request_from_chip(chip, index, con_id ?: dev_id);
 
 	mutex_unlock(&pwm_lookup_lock);
-- 
1.7.0.4

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ