qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: AlexChen <alex.chen@huawei.com>
To: Raphael Norwitz <raphael.s.norwitz@gmail.com>
Cc: qemu-trivial@nongnu.org, QEMU <qemu-devel@nongnu.org>,
	Raphael Norwitz <raphael.norwitz@nutanix.com>
Subject: Re: [PATCH] vhost-user-blk: Fix two resource leaks
Date: Thu, 29 Oct 2020 13:58:32 +0800	[thread overview]
Message-ID: <5F9A5A08.3090507@huawei.com> (raw)
In-Reply-To: <CAFubqFv0m9BeAvmCCkv9iEMvUXfHP2z+HJ8ffkOG4KONig2LHQ@mail.gmail.com>

On 2020/10/28 23:40, Raphael Norwitz wrote:
> The change looks good but I'm not sure I'd call it resource leak in
> either case since the failure case kills vhost-user-blk/scsi. In the
> commit message maybe rather say "vhost-user-blk/scsi: fix broken error
> handling for socket call"?
>

Thanks for your suggestion. I will modify the commit message in next version.

Thanks,
Alex

> On Wed, Oct 28, 2020 at 10:10 AM AlexChen <alex.chen@huawei.com> wrote:
>>
>> When socket() fails, it returns -1, 0 is the normal return value and should not return
>>
>> Reported-by: Euler Robot <euler.robot@huawei.com>
>> Signed-off-by: AlexChen <alex.chen@huawei.com>
>> ---
>>  contrib/vhost-user-blk/vhost-user-blk.c   | 2 +-
>>  contrib/vhost-user-scsi/vhost-user-scsi.c | 2 +-
>>  2 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c
>> index 25eccd02b5..40a2dfc544 100644
>> --- a/contrib/vhost-user-blk/vhost-user-blk.c
>> +++ b/contrib/vhost-user-blk/vhost-user-blk.c
>> @@ -474,7 +474,7 @@ static int unix_sock_new(char *unix_fn)
>>      assert(unix_fn);
>>
>>      sock = socket(AF_UNIX, SOCK_STREAM, 0);
>> -    if (sock <= 0) {
>> +    if (sock < 0) {
>>          perror("socket");
>>          return -1;
>>      }
>> diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c b/contrib/vhost-user-scsi/vhost-user-scsi.c
>> index 3c912384e9..0f9ba4b2a2 100644
>> --- a/contrib/vhost-user-scsi/vhost-user-scsi.c
>> +++ b/contrib/vhost-user-scsi/vhost-user-scsi.c
>> @@ -320,7 +320,7 @@ static int unix_sock_new(char *unix_fn)
>>      assert(unix_fn);
>>
>>      sock = socket(AF_UNIX, SOCK_STREAM, 0);
>> -    if (sock <= 0) {
>> +    if (sock < 0) {
>>          perror("socket");
>>          return -1;
>>      }
>> --
>> 2.19.1
>>
> .
> 



  reply	other threads:[~2020-10-29  5:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-28 14:09 [PATCH] vhost-user-blk: Fix two resource leaks AlexChen
2020-10-28 15:40 ` Raphael Norwitz
2020-10-29  5:58   ` AlexChen [this message]
2020-10-29  6:03 ` [PATCH V2] vhost-user-blk/scsi: Fix broken error handling for socket call AlexChen
2020-10-29 16:41   ` Raphael Norwitz
2020-11-12 15:48   ` Peter Maydell
2020-11-14 16:46   ` Michael S. Tsirkin

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=5F9A5A08.3090507@huawei.com \
    --to=alex.chen@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=raphael.norwitz@nutanix.com \
    --cc=raphael.s.norwitz@gmail.com \
    /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).