Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Evergreen:11.1:Test
multipath-tools
multipath-tools-more-memory-leaks
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File multipath-tools-more-memory-leaks of Package multipath-tools
commit 9683f8fb5a1e6ee12444f1b9fdd751bf2b6daefb Author: Hannes Reinecke <hare@suse.de> Date: Wed Jan 28 09:24:10 2009 +0100 Plug memory leaks Running the internal memory checker revealed quite some memory leaks. Signed-off-by: Hannes Reinecke <hare@suse.de> diff --git a/libmultipath/blacklist.c b/libmultipath/blacklist.c index 7db43c6..f369517 100644 --- a/libmultipath/blacklist.c +++ b/libmultipath/blacklist.c @@ -51,10 +51,10 @@ alloc_ble_device (vector blist) { struct blentry_device * ble = MALLOC(sizeof(struct blentry_device)); - if (!ble || !blist) + if (!ble) return 1; - if (!vector_alloc_slot(blist)) { + if (!blist || !vector_alloc_slot(blist)) { FREE(ble); return 1; } @@ -70,7 +70,7 @@ set_ble_device (vector blist, char * vendor, char * product, int origin) if (!blist) return 1; - ble = VECTOR_SLOT(blist, VECTOR_SIZE(blist) - 1); + ble = VECTOR_LAST_SLOT(blist); if (!ble) return 1; @@ -345,10 +345,14 @@ free_blacklist_device (vector blist) vector_foreach_slot (blist, ble, i) { if (ble) { - regfree(&ble->vendor_reg); - regfree(&ble->product_reg); - FREE(ble->vendor); - FREE(ble->product); + if (ble->vendor) { + regfree(&ble->vendor_reg); + FREE(ble->vendor); + } + if (ble->product) { + regfree(&ble->product_reg); + FREE(ble->product); + } FREE(ble); } } diff --git a/libmultipath/config.c b/libmultipath/config.c index 58485c6..66cefd8 100644 --- a/libmultipath/config.c +++ b/libmultipath/config.c @@ -168,6 +168,9 @@ free_hwe (struct hwentry * hwe) if (hwe->prio_name) FREE(hwe->prio_name); + if (hwe->prio_arg) + FREE(hwe->prio_arg); + if (hwe->bl_product) FREE(hwe->bl_product); @@ -275,7 +278,7 @@ set_param_str(char * str) #define merge_str(s) \ if (hwe2->s) { \ if (hwe1->s) \ - free(hwe1->s); \ + FREE(hwe1->s); \ if (!(hwe1->s = set_param_str(hwe2->s))) \ return 1; \ } diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c index 713db6a..c848ea8 100644 --- a/libmultipath/devmapper.c +++ b/libmultipath/devmapper.c @@ -213,7 +213,7 @@ dm_addmap (int task, const char *name, const char *target, freeout: if (prefixed_uuid) - free(prefixed_uuid); + FREE(prefixed_uuid); addout: dm_task_destroy (dmt); @@ -1010,8 +1010,11 @@ dm_get_info (char * mapname, struct dm_info ** dmi) r = 0; out: - if (r) + if (r) { memset(*dmi, 0, sizeof(struct dm_info)); + FREE(*dmi); + *dmi = NULL; + } if (dmt) dm_task_destroy(dmt); diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c index 33b5cde..91fcda0 100644 --- a/libmultipath/dmparser.c +++ b/libmultipath/dmparser.c @@ -197,7 +197,8 @@ disassemble_map (vector pathvec, char * params, struct multipath * mpp) if (!mpp->pg) return 1; - } + } else + mpp->pg = NULL; /* * first pg to try @@ -291,7 +292,7 @@ disassemble_map (vector pathvec, char * params, struct multipath * mpp) /* Only call this in multipath client mode */ if (!mpp->waiter && store_path(pathvec, pp)) - goto out; + goto out1; } FREE(word); diff --git a/libmultipath/parser.c b/libmultipath/parser.c index 62eb712..ca0f9a9 100644 --- a/libmultipath/parser.c +++ b/libmultipath/parser.c @@ -318,8 +318,10 @@ read_value_block(void) dup = (char *) MALLOC(strlen(str) + 1); memcpy(dup, str, strlen(str)); - if (!vector_alloc_slot(elements)) + if (!vector_alloc_slot(elements)) { + free_strvec(vec); goto out1; + } vector_set_slot(elements, dup); } diff --git a/libmultipath/structs.c b/libmultipath/structs.c index d2bfc2d..82df680 100644 --- a/libmultipath/structs.c +++ b/libmultipath/structs.c @@ -79,8 +79,10 @@ alloc_pathgroup (void) pgp->paths = vector_alloc(); - if (!pgp->paths) + if (!pgp->paths) { FREE(pgp); + pgp = NULL; + } return pgp; } @@ -166,8 +168,10 @@ free_multipath (struct multipath * mpp, int free_paths) mpp->alias = NULL; } - if (mpp->dmi) + if (mpp->dmi) { FREE(mpp->dmi); + mpp->dmi = NULL; + } /* * better own vecs->lock here diff --git a/libmultipath/structs_vec.c b/libmultipath/structs_vec.c index 4135fc1..9b45204 100644 --- a/libmultipath/structs_vec.c +++ b/libmultipath/structs_vec.c @@ -283,6 +283,7 @@ extern int update_multipath_strings (struct multipath *mpp, vector pathvec) { condlog(4, "%s: %s", mpp->alias, __FUNCTION__); + free_multipath_attributes(mpp); free_pgvec(mpp->pg, KEEP_PATHS); mpp->pg = NULL; @@ -395,8 +396,10 @@ add_map_without_path (struct vectors * vecs, mpp->alias = alias; - if (setup_multipath(vecs, mpp)) + if (setup_multipath(vecs, mpp)) { + mpp->alias = NULL; return NULL; /* mpp freed in setup_multipath */ + } if (adopt_paths(vecs->pathvec, mpp)) goto out; diff --git a/multipathd/cli.c b/multipathd/cli.c index acc8cab..1d781b7 100644 --- a/multipathd/cli.c +++ b/multipathd/cli.c @@ -230,8 +230,10 @@ get_cmdvec (char * cmd, vector *v) cmdvec = vector_alloc(); *v = cmdvec; - if (!cmdvec) + if (!cmdvec) { + free_strvec(strvec); return E_NOMEM; + } vector_foreach_slot(strvec, buff, i) { if (*buff == '"') @@ -266,6 +268,7 @@ get_cmdvec (char * cmd, vector *v) r = E_NOPARM; goto out; } + free_strvec(strvec); return 0; out: @@ -374,6 +377,7 @@ parse_cmd (char * cmd, char ** reply, int * len, void * data) if (!h) { *reply = genhelp_handler(); *len = strlen(*reply) + 1; + free_keys(cmdvec); return 0; } diff --git a/multipathd/main.c b/multipathd/main.c index 5456a6c..ec37c2d 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -249,6 +249,7 @@ ev_add_map (char * dev, int major, int minor, struct vectors * vecs) if (map_present && dm_type(alias, TGT_MPATH) <= 0) { condlog(4, "%s: not a multipath map", alias); + FREE(alias); return 0; } @@ -261,6 +262,7 @@ ev_add_map (char * dev, int major, int minor, struct vectors * vecs) * of uev_add_path */ condlog(0, "%s: devmap already registered", dev); + FREE(alias); return 0; }
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor