qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Li Qiang <liq3ea@163.com>, kraxel@redhat.com
Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org,
	Michael Hanselmann <public@hansmi.ch>
Subject: Re: [Qemu-devel] [PATCH] usb: dev-mtp: close fd in usb_mtp_object_readdir()
Date: Thu, 3 Jan 2019 14:45:02 +0100	[thread overview]
Message-ID: <c26ddf38-15e9-8fe8-382c-1388c134a149@redhat.com> (raw)
In-Reply-To: <20190103133113.49599-1-liq3ea@163.com>

On 1/3/19 2:31 PM, Li Qiang wrote:
> Spotted by Coverity: CID 1397070

Closing a CVE to open a CID :)

Fixes: bab9df35ce

> 
> Signed-off-by: Li Qiang <liq3ea@163.com>
> ---
>  hw/usb/dev-mtp.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
> index b19b576278..666bafd9e8 100644
> --- a/hw/usb/dev-mtp.c
> +++ b/hw/usb/dev-mtp.c
> @@ -666,6 +666,7 @@ static void usb_mtp_object_readdir(MTPState *s, MTPObject *o)
>      }
>      dir = fdopendir(fd);
>      if (!dir) {
> +        close(fd);
>          return;

This or:

           goto cleanup_fd;

>      }
>  #ifdef CONFIG_INOTIFY1
> @@ -682,6 +683,7 @@ static void usb_mtp_object_readdir(MTPState *s, MTPObject *o)
>          usb_mtp_add_child(s, o, entry->d_name);
>      }
>      closedir(dir);

And:

cleanup_fd:

> +    close(fd);
>  }
>  
>  /* ----------------------------------------------------------------------- */
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

  reply	other threads:[~2019-01-03 13:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-03 13:31 [Qemu-devel] [PATCH] usb: dev-mtp: close fd in usb_mtp_object_readdir() Li Qiang
2019-01-03 13:45 ` Philippe Mathieu-Daudé [this message]
2019-01-07 10:22 ` Gerd Hoffmann
2019-01-07 10:35   ` Peter Maydell
2019-01-11 10:50     ` Gerd Hoffmann

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=c26ddf38-15e9-8fe8-382c-1388c134a149@redhat.com \
    --to=philmd@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=liq3ea@163.com \
    --cc=peter.maydell@linaro.org \
    --cc=public@hansmi.ch \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).