Aah. ookey.. so it needs to be moved two lines below.. What about the caller of the function? is it getting closed at any stage? ________________________________________ From: Jan Engelhardt [jengelh@xxxxxxx] Sent: 07 September 2015 13:41 To: Zaman, Imran Cc: netfilter-devel@xxxxxxxxxxxxxxx Subject: Re: [PATCH v1 1/1] fix: resource leakage when loading library using dlopen On Monday 2015-09-07 12:42, Imran Zaman wrote: >@@ -579,7 +580,8 @@ static void *load_extension(const char *search_path, const char *af_prefix, > strerror(errno)); > return NULL; > } >- if (dlopen(path, RTLD_NOW) == NULL) { >+ handle = dlopen(path, RTLD_NOW); >+ if (handle == NULL) { > fprintf(stderr, "%s: %s\n", path, dlerror()); > break; > } >@@ -590,6 +592,7 @@ static void *load_extension(const char *search_path, const char *af_prefix, > ptr = xtables_find_match(name, > XTF_DONT_LOAD, NULL); > >+ dlclose(handle); > if (ptr != NULL) > return ptr; > Seriously? If you close the handle, then ptr->init will point to invalid memory and the thing should crash. --------------------------------------------------------------------- Intel Finland Oy Registered Address: PL 281, 00181 Helsinki Business Identity Code: 0357606 - 4 Domiciled in Helsinki This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html