DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Burakov, Anatoly" <anatoly.burakov@intel.com>
To: "Tan, Jianfeng" <jianfeng.tan@intel.com>, dev@dpdk.org
Cc: thomas@monjalon.net
Subject: Re: [dpdk-dev] [PATCH 2/2] eal: fix not checking unlock result
Date: Wed, 25 Apr 2018 09:53:15 +0100	[thread overview]
Message-ID: <213a4fe8-463e-adf5-bf81-44c00abd1697@intel.com> (raw)
In-Reply-To: <7d1afc66-f8ce-44c8-7518-7cb641d9aac9@intel.com>

On 25-Apr-18 8:09 AM, Tan, Jianfeng wrote:
> 
> 
> On 4/17/2018 11:42 PM, Anatoly Burakov wrote:
>> Coverity issue: 272607
>>
>> Fixes: 66cc45e293ed ("mem: replace memseg with memseg lists")
>> Cc: anatoly.burakov@intel.com
>>
>> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
>> ---
>>   lib/librte_eal/linuxapp/eal/eal_hugepage_info.c | 7 +++++--
>>   1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c 
>> b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c
>> index 009f963..01fee51 100644
>> --- a/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c
>> +++ b/lib/librte_eal/linuxapp/eal/eal_hugepage_info.c
>> @@ -304,8 +304,11 @@ clear_hugedir(const char * hugedir)
>>           /* if lock succeeds, unlock and remove the file */
>>           if (lck_result != -1) {
>>               lck.l_type = F_UNLCK;
>> -            fcntl(fd, F_SETLK, &lck);
>> -            unlinkat(dir_fd, dirent->d_name, 0);
>> +            if (fcntl(fd, F_SETLK, &lck) < 0)
>> +                RTE_LOG(ERR, EAL, "Couldn't unlock %s: %s\n",
>> +                    dirent->d_name, strerror(errno));
> 
> It seems that we shall return error if this nearly-impossible error 
> happens, no?

I'm not sure if we should. In any case, lock will be dropped by close(), 
so the proper fix would've been just remove the fcntl() call altogether.

I'll respin.

> 
>> +            else
>> +                unlinkat(dir_fd, dirent->d_name, 0);
>>           }
>>           close (fd);
>>           dirent = readdir(dir);
> 
> 


-- 
Thanks,
Anatoly

  reply	other threads:[~2018-04-25  8:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-17 15:42 [dpdk-dev] [PATCH 0/2] Coverity fixes for EAL Anatoly Burakov
2018-04-17 15:42 ` [dpdk-dev] [PATCH 1/2] eal: fix potential negative return Anatoly Burakov
2018-04-25  5:55   ` Tan, Jianfeng
2018-04-17 15:42 ` [dpdk-dev] [PATCH 2/2] eal: fix not checking unlock result Anatoly Burakov
2018-04-25  7:09   ` Tan, Jianfeng
2018-04-25  8:53     ` Burakov, Anatoly [this message]
2018-04-25 10:08 ` [dpdk-dev] [PATCH v2] Coverity fixes for EAL Anatoly Burakov
2018-04-25 10:08 ` [dpdk-dev] [PATCH v2] eal: remove call to unlock Anatoly Burakov
2018-04-25 10:32   ` Thomas Monjalon

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=213a4fe8-463e-adf5-bf81-44c00abd1697@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=jianfeng.tan@intel.com \
    --cc=thomas@monjalon.net \
    /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;
as well as URLs for NNTP newsgroup(s).