Re: [PATCH] eepromer/24cXX: fix leaking file descriptor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jean Delvare <khali@xxxxxxxxxxxx> writes:

> Hi Nikola,
>
> Patches for i2c-tools are better sent to the linux-i2c list,
> redirecting.
>
> On Tue, 24 Apr 2012 12:24:54 +0200, Nikola Pajkovsky wrote:
>> Signed-off-by: Nikola Pajkovsky <npajkovs@xxxxxxxxxx>
>> ---
>>  eepromer/24cXX.c |    5 +++--
>>  1 file changed, 3 insertions(+), 2 deletions(-)
>> 
>> diff --git a/eepromer/24cXX.c b/eepromer/24cXX.c
>> index 00a21fd..ab86c33 100644
>> --- a/eepromer/24cXX.c
>> +++ b/eepromer/24cXX.c
>> @@ -79,9 +79,10 @@ int eeprom_open(char *dev_fqn, int addr, int type, struct eeprom* e)
>>  		return -1;
>>  
>>  	// get funcs list
>> -	if((r = ioctl(fd, I2C_FUNCS, &funcs) < 0))
>> +	if((r = ioctl(fd, I2C_FUNCS, &funcs) < 0)) {
>> +		close(fd);
>>  		return r;
>> -
>> +	}
>>  	
>>  	// check for req funcs
>>  	CHECK_I2C_FUNC( funcs, I2C_FUNC_SMBUS_READ_BYTE );
>
> Good catch, however this function is leaking the same file descriptor
> in 7 other cases (one obvious one plus six times in CHECK_I2C_FUNC.) If
> we fix one, we should fix them all. I'd also be happy to get rid of
> CHECK_I2C_FUNC as it exists, macro-generated code is evil. I see no
> good reason why this couldn't be implemented as a regular function
> instead.
>
> Will you send updated patches, or do you want me to take care of these
> changes?

aha, I didn't look at it so deeper. Nevertheless I'll prepare another
patches.

-- 
Nikola
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux