Skip to contentSkip to conversation

dmar: Fix double free in error paths following c/s a8bc99b

PATCH In review Andrew Cooper 3 participants 3 messages Jul 16, 2015 – Jul 20, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dmar: Fix double free in error paths following c/s a8bc99b

Several error paths would end up freeing scope->devices twice.

CC Jan Beulich <[email protected]>
CC Elena Ufimtseva <[email protected]>
CC Yang Zhang <[email protected]>
CC Kevin Tian <[email protected]>
---
 xen/drivers/passthrough/vtd/dmar.c |    1 +
 1 file changed, 1 insertion(+)
xen/drivers/passthrough/vtd/dmar.c +1 -0
index 8ed1e24..2672688 100644
@@ -88,6 +88,7 @@ static void scope_devices_free(struct dmar_scope *scope)
 
     scope->devices_cnt = 0;
     xfree(scope->devices);
+    scope->devices = NULL;
 }
 
 static void __init disable_all_dmar_units(void)
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 2 lines
Quoted 1 line
Quoted 1 line · On 16.07.15 at 13:57, <[email protected]> wrote:

Several error paths would end up freeing scope->devices twice.

Of course it depends how you count, but I can spot exactly one broken case - in acpi_parse_dev_scope(). All other callers of scope_devices_free() free the container right afterwards afaics.

Jan

Acked-by on v1 1/1
#2 lore raw
In reply to Andrew Cooper
Quoted 10 lines

From: Andrew Cooper [mailto:[email protected]]
Sent: Thursday, July 16, 2015 7:57 PM

Several error paths would end up freeing scope->devices twice.

CC Jan Beulich <[email protected]>
CC Elena Ufimtseva <[email protected]>
CC Yang Zhang <[email protected]>
CC Kevin Tian <[email protected]>
Quoted 18 lines
---
 xen/drivers/passthrough/vtd/dmar.c |    1 +
 1 file changed, 1 insertion(+)
xen/drivers/passthrough/vtd/dmar.c +1 -1
index 8ed1e24..2672688 100644
@@ -88,6 +88,7 @@ static void scope_devices_free(struct dmar_scope *scope)
 
     scope->devices_cnt = 0;
     xfree(scope->devices);
+    scope->devices = NULL;
 }
 
 static void __init disable_all_dmar_units(void)
--

1.7.10.4