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>] [day] [month] [year] [list]
Message-Id: <1399842349-22395-1-git-send-email-vincent.stehle@laposte.net>
Date:	Sun, 11 May 2014 23:05:49 +0200
From:	Vincent Stehlé <vincent.stehle@...oste.net>
To:	linux-kernel@...r.kernel.org
Cc:	Vincent Stehlé <vincent.stehle@...oste.net>,
	Dmitry Eremin-Solenikov <dbaryshkov@...il.com>,
	David Woodhouse <dwmw2@...radead.org>
Subject: [PATCH] ab8500-fg: Fix use of uninitialized variable in error path

Fix the use of an uninitialized variable i as iterator (instead of j) in
function ab8500_fg_sysfs_psy_create_attrs error path.

This fixes the following compilation warning:

  drivers/power/ab8500_fg.c: In function ‘ab8500_fg_probe’:
  drivers/power/ab8500_fg.c:2989:27: warning: ‘i’ may be used uninitialized in this function [-Wuninitialized]
  drivers/power/ab8500_fg.c:2972:15: note: ‘i’ was declared here

While at it, remove j and use i instead, to stay consistent with the driver's
coding style, and split line for checkpatch.pl.

Signed-off-by: Vincent Stehlé <vincent.stehle@...oste.net>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@...il.com>
Cc: David Woodhouse <dwmw2@...radead.org>
---

Hi,

This starts from a compilation warning but is most probably a real bug.

This can be seen with e.g. mainline and x86 allyesconfig.

Best regards,

V.

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

diff --git a/drivers/power/ab8500_fg.c b/drivers/power/ab8500_fg.c
index 3cb4178..fb65ea2 100644
--- a/drivers/power/ab8500_fg.c
+++ b/drivers/power/ab8500_fg.c
@@ -2969,7 +2969,7 @@ static struct device_attribute ab8505_fg_sysfs_psy_attrs[] = {
 
 static int ab8500_fg_sysfs_psy_create_attrs(struct device *dev)
 {
-	unsigned int i, j;
+	unsigned int i;
 	struct power_supply *psy = dev_get_drvdata(dev);
 	struct ab8500_fg *di;
 
@@ -2978,14 +2978,15 @@ static int ab8500_fg_sysfs_psy_create_attrs(struct device *dev)
 	if (((is_ab8505(di->parent) || is_ab9540(di->parent)) &&
 	     abx500_get_chip_id(dev->parent) >= AB8500_CUT2P0)
 	    || is_ab8540(di->parent)) {
-		for (j = 0; j < ARRAY_SIZE(ab8505_fg_sysfs_psy_attrs); j++)
-			if (device_create_file(dev, &ab8505_fg_sysfs_psy_attrs[j]))
+		for (i = 0; i < ARRAY_SIZE(ab8505_fg_sysfs_psy_attrs); i++)
+			if (device_create_file(dev,
+						&ab8505_fg_sysfs_psy_attrs[i]))
 				goto sysfs_psy_create_attrs_failed_ab8505;
 	}
 	return 0;
 sysfs_psy_create_attrs_failed_ab8505:
 	dev_err(dev, "Failed creating sysfs psy attrs for ab8505.\n");
-	while (j--)
+	while (i--)
 		device_remove_file(dev, &ab8505_fg_sysfs_psy_attrs[i]);
 
 	return -EIO;
-- 
2.0.0.rc0

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