Skip to contentSkip to conversation

libxlu: handle NULL pointer in xlu_cfg_destroy

PATCH Applied Olaf Hering 3 participants 3 messages May 7, 2015 – May 8, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxlu: handle NULL pointer in xlu_cfg_destroy

Handle NULL pointer passed to xlu_cfg_destroy. libvirt calls it in its libxlDriverConfigDispose function. If the XLU_Config was not initialized yet for some reason a crash would occour on cleanup.
Avoid the crash just like libxl_ctx_free and xtl_logger_destroy do when called from the same context.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Wei Liu <[email protected]>

---

Not sure if this is correct, or if libvirt should call this function only if cfg is valid.

If this patch gets applied I suggest to apply this also to maintained trees.

 tools/libxl/libxlu_cfg.c | 1 +
 1 file changed, 1 insertion(+)
tools/libxl/libxlu_cfg.c +1 -0
index 0a59b52..1d70909 100644
@@ -159,6 +159,7 @@ void xlu__cfg_set_free(XLU_ConfigSetting *set) {
 void xlu_cfg_destroy(XLU_Config *cfg) {
     XLU_ConfigSetting *set, *set_next;
 
+    if (!cfg) return;
     for (set= cfg->settings;
          set;
          set= set_next) {
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Olaf Hering

Handle NULL pointer passed to xlu_cfg_destroy. libvirt calls it in its libxlDriverConfigDispose function. If the XLU_Config was not initialized yet for some reason a crash would occour on cleanup.
Avoid the crash just like libxl_ctx_free and xtl_logger_destroy do when called from the same context.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Wei Liu <[email protected]>
Quoted 24 lines

---

Not sure if this is correct, or if libvirt should call this function only if cfg is valid.

If this patch gets applied I suggest to apply this also to maintained trees.

 tools/libxl/libxlu_cfg.c | 1 +
 1 file changed, 1 insertion(+)
tools/libxl/libxlu_cfg.c +1 -0
index 0a59b52..1d70909 100644
@@ -159,6 +159,7 @@ void xlu__cfg_set_free(XLU_ConfigSetting *set) {
 void xlu_cfg_destroy(XLU_Config *cfg) {
     XLU_ConfigSetting *set, *set_next;
 
+    if (!cfg) return;
     for (set= cfg->settings;
          set;
          set= set_next) {
Applied
#2 lore raw
Quoted 4 lines · Wei Liu
Quoted 3 lines · Olaf Hering

Handle NULL pointer passed to xlu_cfg_destroy. libvirt calls it in its libxlDriverConfigDispose function. If the XLU_Config was not initialized yet for some reason a crash would occour on cleanup.

"occur"

Quoted 10 lines
Quoted 8 lines

Avoid the crash just like libxl_ctx_free and xtl_logger_destroy do when called from the same context.

Cc Ian Jackson <[email protected]>
Cc Stefano Stabellini <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Wei Liu <[email protected]>

Applied, fixing the typo.

Quoted 24 lines
Quoted 24 lines

---

Not sure if this is correct, or if libvirt should call this function only if cfg is valid.

If this patch gets applied I suggest to apply this also to maintained trees.

 tools/libxl/libxlu_cfg.c | 1 +
 1 file changed, 1 insertion(+)
tools/libxl/libxlu_cfg.c +1 -0
index 0a59b52..1d70909 100644
@@ -159,6 +159,7 @@ void xlu__cfg_set_free(XLU_ConfigSetting *set) {
 void xlu_cfg_destroy(XLU_Config *cfg) {
     XLU_ConfigSetting *set, *set_next;
 
+    if (!cfg) return;
     for (set= cfg->settings;
          set;
          set= set_next) {