From: Li Qiang Date: Thu, 3 Jan 2019 13:31:13 +0000 (-0800) Subject: usb: dev-mtp: close fd in usb_mtp_object_readdir() X-Git-Tag: v4.0.0-rc0~130^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6e3c1a68f91d8de2a800d994edf0c9eedde6f090;p=thirdparty%2Fqemu.git usb: dev-mtp: close fd in usb_mtp_object_readdir() Spotted by Coverity: CID 1397070 Signed-off-by: Li Qiang Reviewed-by: Philippe Mathieu-Daudé 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 --- diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c index 68c5eb8eaa4..837c9d94498 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; } #ifdef CONFIG_INOTIFY1