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: <11091080.93181313475012613.JavaMail.weblogic@epml13>
Date:	Tue, 16 Aug 2011 06:10:13 +0000 (GMT)
From:	MyungJoo Ham <myungjoo.ham@...sung.com>
To:	Philip Rakity <prakity@...vell.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Cc:	Anton Vorontsov <cbouatmailru@...il.com>,
	¹Ú°æ¹Î <kyungmin.park@...sung.com>
Subject: Re: [PATCH] power: max17042: divide by 0 Crash because r_sns init too
 late

Philip Rakity<prakity@...vell.com> Date : 2011-08-13 13:18 (GMT+09:00)
> On MMP2 brownstone divide by 0 error since probe sets r_sns
> after calling power_supply_register.
> 
> Move the code up a few lines.  r_sns comes from the platform
> data.
> 
> PROP_CURRENT_AVG and PROP_CURRENT divide the result by r_sns.
> 
> Signed-off-by: Philip Rakity 

Acked-by: MyungJoo Ham <myungjoo.ham@...sung.com>

> ---
> drivers/power/max17042_battery.c |    6 +++---
> 1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/power/max17042_battery.c b/drivers/power/max17042_battery.c
> index 9f0183c..4245806 100644
> --- a/drivers/power/max17042_battery.c
> +++ b/drivers/power/max17042_battery.c
> @@ -210,6 +210,9 @@ static int __devinit max17042_probe(struct i2c_client *client,
> if (!chip->pdata->enable_current_sense)
> chip->battery.num_properties -= 2;
> 
> + if (chip->pdata->r_sns == 0)
> + chip->pdata->r_sns = MAX17042_DEFAULT_SNS_RESISTOR;
> +
> ret = power_supply_register(&client->dev, &chip->battery);
> if (ret) {
> dev_err(&client->dev, "failed: power supply register\n");
> @@ -226,9 +229,6 @@ static int __devinit max17042_probe(struct i2c_client *client,
> max17042_write_reg(client, MAX17042_CGAIN, 0x0000);
> max17042_write_reg(client, MAX17042_MiscCFG, 0x0003);
> max17042_write_reg(client, MAX17042_LearnCFG, 0x0007);
> - } else {
> - if (chip->pdata->r_sns == 0)
> - chip->pdata->r_sns = MAX17042_DEFAULT_SNS_RESISTOR;
> }
> 
> return 0;
> -- 
> 1.7.0.4
> 
> 

 MyungJoo Ham (ÇÔ¸íÁÖ)
Mobile Software Platform Lab,
Digital Media and Communications (DMC) Business
Samsung Electronics
cell: +82-10-6714-2858 / office: +82-31-279-8033

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ