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] [thread-next>] [day] [month] [year] [list]
Message-ID: <547D99DE.6030309@nod.at>
Date:	Tue, 02 Dec 2014 11:52:14 +0100
From:	Richard Weinberger <richard@....at>
To:	Harald Geyer <harald@...ib.org>
CC:	jic23@...nel.org, knaack.h@....de, lars@...afoo.de,
	pmeerw@...erw.net, sanjeev_sharma@...tor.com,
	linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] iio: dht11: Add locking

Harald,

Am 02.12.2014 um 11:07 schrieb Harald Geyer:
> Hi Richard,
> 
> thanks for the patch. Comments inline.
> 
> Richard Weinberger writes:
>> Protect the read function from concurrent reads.
>>
>> Signed-off-by: Richard Weinberger <richard@....at>
>> ---
>>  drivers/iio/humidity/dht11.c | 19 ++++++++++++++-----
>>  1 file changed, 14 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/iio/humidity/dht11.c b/drivers/iio/humidity/dht11.c
>> index 623c145..7636e66 100644
>> --- a/drivers/iio/humidity/dht11.c
>> +++ b/drivers/iio/humidity/dht11.c
> 
> #include <linux/mutex.h>
> 
>> @@ -57,6 +57,7 @@ struct dht11 {
>>  	int				irq;
>>  
>>  	struct completion		completion;
>> +	struct mutex			lock;
>>  
>>  	s64				timestamp;
>>  	int				temperature;
>> @@ -146,16 +147,17 @@ static int dht11_read_raw(struct iio_dev *iio_dev,
>>  	int ret;
>>  
>>  	if (dht11->timestamp + DHT11_DATA_VALID_TIME < iio_get_time_ns()) {
>> +		mutex_lock(&dht11->lock);
> 
> Move the locking out of the if statement.

Care to explain why?

But I found another issue in my patch.
The "dht11->num_edges = -1;" before "return ret" needs to go into the locked area.
Will send an updated version soon.

> BTW, it seems that there is already locking around read_raw() in the
> in-kernel consumer interface but not in the sysfs interface. Is there
> any reason for this difference?

Dunno. :-)

Thanks,
//richard
--
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