[lvm-devel] master - coverity: fix possible NULL dereference

Peter Rajnoha prajnoha at fedoraproject.org
Wed Nov 26 10:51:55 UTC 2014


Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=193f9b26a0a87b2f5ce9a308ea0d957fadfe4aeb
Commit:        193f9b26a0a87b2f5ce9a308ea0d957fadfe4aeb
Parent:        86ae68a5f7e396a6584b8003667b44a433d914fd
Author:        Peter Rajnoha <prajnoha at redhat.com>
AuthorDate:    Wed Nov 26 11:46:13 2014 +0100
Committer:     Peter Rajnoha <prajnoha at redhat.com>
CommitterDate: Wed Nov 26 11:46:13 2014 +0100

coverity: fix possible NULL dereference

The call to dm_config_destroy can derefence result->mem
while result is still NULL:

struct dm_config_tree *get_cachepolicy_params(struct cmd_context *cmd)
{
	...
	int ok = 0;
	...
	if (!(result = dm_config_flatten(current)))
		goto_out;
	...
	ok = 1;
out:
	 if (!ok) {
		dm_config_destroy(result)
		...
	}
	...
}
---
 tools/toollib.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/tools/toollib.c b/tools/toollib.c
index ddf2dcf..71eb9a8 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -1175,7 +1175,7 @@ struct dm_config_tree *get_cachepolicy_params(struct cmd_context *cmd)
 	ok = 1;
 
 out:
-	if (!ok) {
+	if (!ok && result) {
 		dm_config_destroy(result);
 		result = NULL;
 	}




More information about the lvm-devel mailing list