OSDN Git Service

usb: dev-mtp: close fd in usb_mtp_object_readdir()
authorLi Qiang <liq3ea@163.com>
Thu, 3 Jan 2019 13:31:13 +0000 (05:31 -0800)
committerGerd Hoffmann <kraxel@redhat.com>
Wed, 30 Jan 2019 05:47:52 +0000 (06:47 +0100)
Spotted by Coverity: CID 1397070

Signed-off-by: Li Qiang <liq3ea@163.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-id: 20190103133113.49599-1-liq3ea@163.com

[ kraxel: dropped chunk which adds close() after successful
          fdopendir() call, that is not needed according to
          POSIX even though Coverity flags it as bug ]

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb/dev-mtp.c

index 68c5eb8..837c9d9 100644 (file)
@@ -666,6 +666,7 @@ static void usb_mtp_object_readdir(MTPState *s, MTPObject *o)
     }
     dir = fdopendir(fd);
     if (!dir) {
+        close(fd);
         return;
     }
 #ifdef CONFIG_INOTIFY1