dm: fix some potential memory leaks

This patch is to fix some potential memory leak issues

1, free mrp if the mmio_rb_lookup() function return 0;
2, free memory allocated by strdup in some error case handling.

Tracked-On: #3277
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
This commit is contained in:
Tianhua Sun 2019-06-14 16:04:47 +08:00 committed by wenlingz
parent b65489c27d
commit 0c0371fc9e
2 changed files with 4 additions and 3 deletions

View File

@ -265,7 +265,7 @@ register_mem_int(struct mmio_rb_tree *rbt, struct mem_range *memp)
struct mmio_rb_range *entry, *mrp;
int err;
err = 0;
err = -1;
mrp = malloc(sizeof(struct mmio_rb_range));
@ -280,8 +280,7 @@ register_mem_int(struct mmio_rb_tree *rbt, struct mem_range *memp)
pthread_rwlock_unlock(&mmio_rwlock);
if (err)
free(mrp);
} else
err = -1;
}
return err;
}

View File

@ -3997,6 +3997,8 @@ errout:
free(xdev->portregs);
xdev->portregs = NULL;
}
if (rc < -2 && s)
free(s);
UPRINTF(LFTL, "fail to parse xHCI options, rc=%d\r\n", rc);
if (opts)