Pair g_malloc() with g_free(), not free()
cover Pair g_malloc() with g_free(), not free()
I'm routing these patches through qemu-trivial, even though some of them touch actively maintained code, and could go through the respective tree instead:
* PATCH 3 sPAPR (Alex)
* PATCH 4 USB (Gerd)
If you want me to reroute any of them, let me know.
Markus Armbruster (4):
qemu-option: Replace pointless use of g_malloc0() by g_malloc()
qemu-option: Pair g_malloc() with g_free(), not free()
spapr_vio: Pair g_malloc() with g_free(), not free()
usb: Pair g_malloc() with g_free(), not free()
hw/ppc/spapr_vio.c | 2 +- hw/usb/desc-msos.c | 2 +- util/qemu-option.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
1.9.3
PATCH 1/4 qemu-option: Replace pointless use of g_malloc0() by g_malloc()
get_opt_value() takes a write-only buffer, so zeroing it is pointless. We don't do it elsewhere, either.
--- util/qemu-option.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
util/qemu-option.c +2 -2
@@ -213,7 +213,7 @@ void parse_option_size(const char *name, const char *value,bool has_help_option (const char *param) {size_t buflen =strlen (param) +1 ; -char *buf =g_malloc0 (buflen); +char *buf =g_malloc (buflen);const char *p = param;bool result = false;
@@ -237,7 +237,7 @@ out:bool is_valid_option_list (const char *param) {size_t buflen =strlen (param) +1 ; -char *buf =g_malloc0 (buflen); +char *buf =g_malloc (buflen);const char *p = param;bool result = true;
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH 1/4] qemu-option: Replace pointless use of g_malloc0() by g_malloc()
Quoted 7 lines · Markus Armbruster
get_opt_value()takes a write-only buffer, so zeroing it is pointless. We don't do it elsewhere, either.Signed-off-by Markus Armbruster <[email protected]>--- util/qemu-option.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
PATCH 2/4 qemu-option: Pair g_malloc() with g_free(), not free()
In reply to Markus ArmbrusterSpotted by Coverity with preview checker ALLOC_FREE_MISMATCH enabled and my "coverity: Model g_free() isn't necessarily free()" model patch applied.
--- util/qemu-option.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
util/qemu-option.c +2 -2
@@ -230,7 +230,7 @@ bool has_help_option(const char *param) } out: -free (buf); +g_free (buf);return result; }
@@ -255,7 +255,7 @@ bool is_valid_option_list(const char *param) } out: -free (buf); +g_free (buf);return result; }
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH 2/4] qemu-option: Pair g_malloc() with g_free(), not free()
Quoted 8 lines · Markus Armbruster
Spotted by Coverity with preview checker
ALLOC_FREE_MISMATCHenabled and my "coverity: Modelg_free()isn't necessarilyfree()" model patch applied.Signed-off-by Markus Armbruster <[email protected]>--- util/qemu-option.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
PATCH 3/4 spapr_vio: Pair g_malloc() with g_free(), not free()
In reply to Markus ArmbrusterSpotted by Coverity with preview checker ALLOC_FREE_MISMATCH enabled and my "coverity: Model g_free() isn't necessarily free()" model patch applied.
--- hw/ppc/spapr_vio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/ppc/spapr_vio.c +1 -1
@@ -648,7 +648,7 @@ int spapr_populate_vdevice(VIOsPAPRBus *bus, void *fdt) ret =0 ; out: -free (qdevs); +g_free (qdevs);return ret; }
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH 3/4] spapr_vio: Pair g_malloc() with g_free(), not free()
Quoted 8 lines · Markus Armbruster
Spotted by Coverity with preview checker
ALLOC_FREE_MISMATCHenabled and my "coverity: Modelg_free()isn't necessarilyfree()" model patch applied.Signed-off-by Markus Armbruster <[email protected]>--- hw/ppc/spapr_vio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH 4/4 usb: Pair g_malloc() with g_free(), not free()
In reply to Markus ArmbrusterSpotted by Coverity with preview checker ALLOC_FREE_MISMATCH enabled and my "coverity: Model g_free() isn't necessarily free()" model patch applied.
--- hw/usb/desc-msos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/usb/desc-msos.c +1 -1
@@ -231,7 +231,7 @@ int usb_desc_msos(const USBDesc *desc, USBPacket *p, length = len; }memcpy (dest, buf, length); -free (buf); +g_free (buf); p->actual_length = length;return 0 ;
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH 4/4] usb: Pair g_malloc() with g_free(), not free()
Quoted 14 lines · Markus Armbruster
Spotted by Coverity with preview checker
ALLOC_FREE_MISMATCHenabled and my "coverity: Modelg_free()isn't necessarilyfree()" model patch applied.Signed-off-by Markus Armbruster <[email protected]>--- hw/usb/desc-msos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/usb/desc-msos.c +0
-0
hw/usb/desc-msos.c int usb_desc_msos(const USBDesc *desc, USBPacket *p, · line 237
Quoted 8 lines
hw/usb/desc-msos.c +1
-1@@ -231,7 +231,7 @@ int usb_desc_msos(const USBDesc *desc, USBPacket *p, length = len; }memcpy (dest, buf, length); -free (buf); +g_free (buf); p->actual_length = length;return 0 ;
This patch had been added Gerd's usb queue :)
http://lists.gnu.org/archive/html/qemu-devel/2015-01/msg01998.html
Regards,
-Gonglei
Quoted 9 lines · Markus Armbruster
I'm routing these patches through qemu-trivial, even though some of them touch actively maintained code, and could go through the respective tree instead:
* PATCH 3 sPAPR (Alex)
* PATCH 4 USB (Gerd)
If you want me to reroute any of them, let me know.
[for patches like these, sometimes I like to use git format-patch -U20 or whatever it takes to make the patch show full context of the allocation a few lines earlier that matches with the actual g_free fix, so that reviewers don't have to open the file themselves. It makes for larger emails, but potentially faster reviews. But it's not the end of the world to stick with the default 3-line context]
Quoted 12 lines
Markus Armbruster (4):
qemu-option: Replace pointless use ofg_malloc0()byg_malloc()
qemu-option: Pairg_malloc()withg_free(), notfree()
spapr_vio: Pairg_malloc()withg_free(), notfree()
usb: Pairg_malloc()withg_free(), notfree()hw/ppc/spapr_vio.c | 2 +- hw/usb/desc-msos.c | 2 +- util/qemu-option.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-)
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Got reviews, want qemu-trivial: *ping* :)
Quoted 20 lines · Markus Armbruster
I'm routing these patches through qemu-trivial, even though some of them touch actively maintained code, and could go through the respective tree instead:
* PATCH 3 sPAPR (Alex)
* PATCH 4 USB (Gerd)
If you want me to reroute any of them, let me know.
Markus Armbruster (4):
qemu-option: Replace pointless use ofg_malloc0()byg_malloc()
qemu-option: Pairg_malloc()withg_free(), notfree()
spapr_vio: Pairg_malloc()withg_free(), notfree()
usb: Pairg_malloc()withg_free(), notfree()hw/ppc/spapr_vio.c | 2 +- hw/usb/desc-msos.c | 2 +- util/qemu-option.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-)
Michael Tokarev
AppliedQuoted 5 lines · Markus Armbruster
Markus Armbruster (4):
qemu-option: Replace pointless use ofg_malloc0()byg_malloc()
qemu-option: Pairg_malloc()withg_free(), notfree()
spapr_vio: Pairg_malloc()withg_free(), notfree()
usb: Pairg_malloc()withg_free(), notfree()
Applied to -trivial, thank you!
/mjt