From: Nikola Pajkovsky <npajkovs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: Linux I2C <linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] eepromer/24cXX: fix leaking file descriptor
Date: Wed, 25 Apr 2012 09:50:48 +0200 [thread overview]
Message-ID: <88fwbs5jxj.fsf@redhat.com> (raw)
In-Reply-To: <20120425084126.317079a9-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org> (Jean Delvare's message of "Wed, 25 Apr 2012 08:41:26 +0200")
Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> 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-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
>> ---
>> 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
prev parent reply other threads:[~2012-04-25 7:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <d53426eaec2f3212842b5a44a0fbc2d1c97f44e3.1335263046.git.npajkovs@redhat.com>
[not found] ` <d53426eaec2f3212842b5a44a0fbc2d1c97f44e3.1335263046.git.npajkovs-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-04-25 6:41 ` [PATCH] eepromer/24cXX: fix leaking file descriptor Jean Delvare
[not found] ` <20120425084126.317079a9-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2012-04-25 7:50 ` Nikola Pajkovsky [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=88fwbs5jxj.fsf@redhat.com \
--to=npajkovs-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox