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]
Message-ID: <5364C220.5010007@kernel.org>
Date:	Sat, 03 May 2014 11:17:04 +0100
From:	Jonathan Cameron <jic23@...nel.org>
To:	Hartmut Knaack <knaack.h@....de>,
	Dan Carpenter <dan.carpenter@...cle.com>
CC:	Lars-Peter Clausen <lars@...afoo.de>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Randy Dunlap <rdunlap@...radead.org>,
	Aida Mynzhasova <ai.c.c0der@...il.com>,
	Masanari Iida <standby24x7@...il.com>,
	linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
	kernel-janitors@...r.kernel.org
Subject: Re: [patch v2] [patch] staging: iio: ad799x: remove some unneeded
 IS_ERR() checks

On 30/04/14 22:52, Hartmut Knaack wrote:
> Dan Carpenter schrieb:
>> My static checker is upset that we check IS_ERR(t->reg) when we know it
>> is not an ERR_PTR.
>>
>> Checking for IS_ERR() twice is often a sign of confusion and buggy code.
>> In this case, if the call to "ret = regulator_enable(st->vref);" fails,
>> then we call "regulator_disable(st->vref);" and that's a mistake because
>> "st->vref" is not enabled.
>>
>> I fixed these problems and Hartmut Knaack pointed out a couple unneeded
>> IS_ERR() checks in ad799x_remove() so I have removed those as well.
>>
>> Signed-off-by: Dan Carpenter <dan.carpenter@...cle.com>
> Acked-by: Hartmut Knaack <knaack.h@....de>
Thanks to both of you for this.

Applied to the togreg branch of iio.git as the cleanup that caused
this was most likely part of a series that is only in staging-next at
the moment.

Jonathan

>> ---
>> v2: remove the unneeded checks in ad799x_remove() as well.  Updated the
>>      commit message to say that it's actually a small bug fix.
>>
>> diff --git a/drivers/iio/adc/ad799x.c b/drivers/iio/adc/ad799x.c
>> index 16a8b14..39b4cb4 100644
>> --- a/drivers/iio/adc/ad799x.c
>> +++ b/drivers/iio/adc/ad799x.c
>> @@ -717,7 +717,7 @@ static int ad799x_probe(struct i2c_client *client,
>>   	ret = iio_triggered_buffer_setup(indio_dev, NULL,
>>   		&ad799x_trigger_handler, NULL);
>>   	if (ret)
>> -		goto error_disable_reg;
>> +		goto error_disable_vref;
>>
>>   	if (client->irq > 0) {
>>   		ret = devm_request_threaded_irq(&client->dev,
>> @@ -739,11 +739,10 @@ static int ad799x_probe(struct i2c_client *client,
>>
>>   error_cleanup_ring:
>>   	iio_triggered_buffer_cleanup(indio_dev);
>> +error_disable_vref:
>> +	regulator_disable(st->vref);
>>   error_disable_reg:
>> -	if (!IS_ERR(st->vref))
>> -		regulator_disable(st->vref);
>> -	if (!IS_ERR(st->reg))
>> -		regulator_disable(st->reg);
>> +	regulator_disable(st->reg);
>>
>>   	return ret;
>>   }
>> @@ -756,10 +755,8 @@ static int ad799x_remove(struct i2c_client *client)
>>   	iio_device_unregister(indio_dev);
>>
>>   	iio_triggered_buffer_cleanup(indio_dev);
>> -	if (!IS_ERR(st->vref))
>> -		regulator_disable(st->vref);
>> -	if (!IS_ERR(st->reg))
>> -		regulator_disable(st->reg);
>> +	regulator_disable(st->vref);
>> +	regulator_disable(st->reg);
>>   	kfree(st->rx_buf);
>>
>>   	return 0;
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>> the body of a message to majordomo@...r.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>

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