Skip to contentSkip to conversation

usb: dev-mtp: fix memory leak in error path

PATCH In review Li Qiang 3 participants 4 messages Jan 3, 2019 – Jan 8, 2019

lore
Share & tools
lore

Li Qiang

author
#0 lore raw

PATCH 1/1 usb: dev-mtp: fix memory leak in error path

Spotted by Coverity: CID 1397074

---
 hw/usb/dev-mtp.c | 1 +
 1 file changed, 1 insertion(+)
hw/usb/dev-mtp.c +1 -0
index 6098005cd4..b19b576278 100644
@@ -1729,6 +1729,7 @@ static void usb_mtp_write_metadata(MTPState *s, uint64_t dlen)
     if (strchr(filename, '/')) {
         usb_mtp_queue_result(s, RES_PARAMETER_NOT_SUPPORTED, d->trans,
                              0, 0, 0, 0);
+        g_free(filename);
         return;
     }
 
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Li Qiang

Spotted by Coverity: CID 1397074

Gerd, if you take this, can you add:

Fixes c52d46e041b
Quoted 1 line
Quoted 17 lines
---
 hw/usb/dev-mtp.c | 1 +
 1 file changed, 1 insertion(+)
hw/usb/dev-mtp.c +1 -0
index 6098005cd4..b19b576278 100644
@@ -1729,6 +1729,7 @@ static void usb_mtp_write_metadata(MTPState *s, uint64_t dlen)
     if (strchr(filename, '/')) {
         usb_mtp_queue_result(s, RES_PARAMETER_NOT_SUPPORTED, d->trans,
                              0, 0, 0, 0);
+        g_free(filename);
         return;
     }
 
author Reviewed-by Philippe Mathieu-Daudé
#2 lore raw

Oh, sorry, I always forget to add this “Fixs: xxx” for these small issues.

Thanks,
Li Qiang

发件人: Philippe Mathieu-Daudé
发送时间: 2019年1月3日 21:38
收件人: Li Qiang; [email protected]
抄送: [email protected]; [email protected]
主题: Re: [Qemu-devel] [PATCH] usb: dev-mtp: fix memory leak in error path

Quoted 2 lines · Li Qiang

Spotted by Coverity: CID 1397074

Gerd, if you take this, can you add:

Fixes c52d46e041b
Quoted 1 line
Quoted 17 lines
---
 hw/usb/dev-mtp.c | 1 +
 1 file changed, 1 insertion(+)
hw/usb/dev-mtp.c +1 -0
index 6098005cd4..b19b576278 100644
@@ -1729,6 +1729,7 @@ static void usb_mtp_write_metadata(MTPState *s, uint64_t dlen)
     if (strchr(filename, '/')) {
         usb_mtp_queue_result(s, RES_PARAMETER_NOT_SUPPORTED, d->trans,
                              0, 0, 0, 0);
+        g_free(filename);
         return;
     }