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-prev] [day] [month] [year] [list]
Date:   Tue, 19 May 2020 12:15:51 -0500
From:   Ricardo Rivera-Matos <r-rivera-matos@...com>
To:     "Andrew F. Davis" <afd@...com>, Dan Murphy <dmurphy@...com>,
        <sre@...nel.org>
CC:     <sspatil@...roid.com>, <linux-pm@...r.kernel.org>,
        <robh@...nel.org>, <linux-kernel@...r.kernel.org>,
        <devicetree@...r.kernel.org>
Subject: Re: [PATCH v7 3/3] power: supply: bq25150 introduce the bq25150


On 5/19/20 9:46 AM, Andrew F. Davis wrote:
> On 5/19/20 10:19 AM, Dan Murphy wrote:
>> +static int bq2515x_set_ilim_lvl(struct bq2515x_device *bq2515x, int val)
>> +{
>> +	int i;
>> +
>> +	if (val > BQ2515X_ILIM_MAX || val < BQ2515X_ILIM_MIN)
>> +		return -EINVAL;
> Clamp to these limits, not reject. Or better, modify the below loop so
> it clamps to the highest or lowest value in bq2515x_ilim_lvl_values[],
> then drop these #defines.
>
>> +
>> +	for (i = 0; i < ARRAY_SIZE(bq2515x_ilim_lvl_values); i++) {
>> +		if (val == bq2515x_ilim_lvl_values[i])
>> +			break;
>> +
>> +		if (val > bq2515x_ilim_lvl_values[i - 1] &&
> Index out of bounds for the i = 0 case.
>
>> +		    val < bq2515x_ilim_lvl_values[i]) {
>> +			if (val - bq2515x_ilim_lvl_values[i - 1] <
>> +			    bq2515x_ilim_lvl_values[i] - val) {
> You are still missing the case where the value is closer to the [i]
> element, you check that it is between [i-1] and [i], but only chose
> [i-1] when it is closer to that than [i] but equal and greater case is
> missing.
>
> Given this sets input current limits, would instead always rounding down
> be the safer option?
>
> Andrew
ACK. I am going to rewrite that altogether.
>
>> +				i = i - 1;
>> +				break;
>> +			}
>> +		}
>> +	}
>> +
>> +	return regmap_write(bq2515x->regmap, BQ2515X_ILIMCTRL, i);
>> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ