* [Qemu-devel] [PATCH] sockets: Plug memory leak in socket_address_flatten()
@ 2017-05-15 16:39 Markus Armbruster
2017-05-15 17:44 ` Eric Blake
0 siblings, 1 reply; 3+ messages in thread
From: Markus Armbruster @ 2017-05-15 16:39 UTC (permalink / raw)
To: qemu-devel
socket_address_flatten() leaks a SocketAddress when its argument is
null. Happens when opening a ChardevBackend of type 'udp' that is
configured without a local address. Screwed up in commit bd269ebc due
to last minute semantic conflict resolution. Spotted by Coverity.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
util/qemu-sockets.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index d8183f7..b39ae74 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -1338,12 +1338,14 @@ char *socket_address_to_string(struct SocketAddress *addr, Error **errp)
SocketAddress *socket_address_flatten(SocketAddressLegacy *addr_legacy)
{
- SocketAddress *addr = g_new(SocketAddress, 1);
+ SocketAddress *addr;
if (!addr_legacy) {
return NULL;
}
+ addr = g_new(SocketAddress, 1);
+
switch (addr_legacy->type) {
case SOCKET_ADDRESS_LEGACY_KIND_INET:
addr->type = SOCKET_ADDRESS_TYPE_INET;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] sockets: Plug memory leak in socket_address_flatten()
2017-05-15 16:39 [Qemu-devel] [PATCH] sockets: Plug memory leak in socket_address_flatten() Markus Armbruster
@ 2017-05-15 17:44 ` Eric Blake
2017-05-16 7:28 ` Markus Armbruster
0 siblings, 1 reply; 3+ messages in thread
From: Eric Blake @ 2017-05-15 17:44 UTC (permalink / raw)
To: Markus Armbruster, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1590 bytes --]
On 05/15/2017 11:39 AM, Markus Armbruster wrote:
> socket_address_flatten() leaks a SocketAddress when its argument is
> null. Happens when opening a ChardevBackend of type 'udp' that is
> configured without a local address. Screwed up in commit bd269ebc due
> to last minute semantic conflict resolution. Spotted by Coverity.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> util/qemu-sockets.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Reviewed-by: Eric Blake <eblake@redhat.com>
Matches the fix I had proposed here against the v2 pull request:
https://lists.gnu.org/archive/html/qemu-devel/2017-05/msg01825.html
I guess in the confusion of the rebasing, you didn't quite implement it
in v3 the way I had proposed.
>
> diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
> index d8183f7..b39ae74 100644
> --- a/util/qemu-sockets.c
> +++ b/util/qemu-sockets.c
> @@ -1338,12 +1338,14 @@ char *socket_address_to_string(struct SocketAddress *addr, Error **errp)
>
> SocketAddress *socket_address_flatten(SocketAddressLegacy *addr_legacy)
> {
> - SocketAddress *addr = g_new(SocketAddress, 1);
> + SocketAddress *addr;
>
> if (!addr_legacy) {
> return NULL;
> }
>
> + addr = g_new(SocketAddress, 1);
> +
> switch (addr_legacy->type) {
> case SOCKET_ADDRESS_LEGACY_KIND_INET:
> addr->type = SOCKET_ADDRESS_TYPE_INET;
>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] sockets: Plug memory leak in socket_address_flatten()
2017-05-15 17:44 ` Eric Blake
@ 2017-05-16 7:28 ` Markus Armbruster
0 siblings, 0 replies; 3+ messages in thread
From: Markus Armbruster @ 2017-05-16 7:28 UTC (permalink / raw)
To: Eric Blake; +Cc: qemu-devel
Eric Blake <eblake@redhat.com> writes:
> On 05/15/2017 11:39 AM, Markus Armbruster wrote:
>> socket_address_flatten() leaks a SocketAddress when its argument is
>> null. Happens when opening a ChardevBackend of type 'udp' that is
>> configured without a local address. Screwed up in commit bd269ebc due
>> to last minute semantic conflict resolution. Spotted by Coverity.
>>
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>> util/qemu-sockets.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> Reviewed-by: Eric Blake <eblake@redhat.com>
>
> Matches the fix I had proposed here against the v2 pull request:
> https://lists.gnu.org/archive/html/qemu-devel/2017-05/msg01825.html
>
> I guess in the confusion of the rebasing, you didn't quite implement it
> in v3 the way I had proposed.
I had started to resolve conflicts myself when the message carrying your
solution arrived, and I obviously screwed up merging it into my unclean
tree. In other words: it's all my fault.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-05-16 7:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-15 16:39 [Qemu-devel] [PATCH] sockets: Plug memory leak in socket_address_flatten() Markus Armbruster
2017-05-15 17:44 ` Eric Blake
2017-05-16 7:28 ` Markus Armbruster
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).