All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zdenek Kabelac <zkabelac@fedoraproject.org>
To: lvm-devel@redhat.com
Subject: master - libdm: add test for dm_task_get_message_response()
Date: Mon,  9 Nov 2015 09:28:31 +0000 (UTC)	[thread overview]
Message-ID: <20151109092831.0654960CD3@fedorahosted.org> (raw)

Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3cadc1c87e4f1f6cede3895a7f7f28f37eaf9648
Commit:        3cadc1c87e4f1f6cede3895a7f7f28f37eaf9648
Parent:        84303dc17aeca9773d5644e4beccc267ab7a3153
Author:        Zdenek Kabelac <zkabelac@redhat.com>
AuthorDate:    Mon Nov 9 09:50:46 2015 +0100
Committer:     Zdenek Kabelac <zkabelac@redhat.com>
CommitterDate: Mon Nov 9 10:19:19 2015 +0100

libdm: add test for  dm_task_get_message_response()

Coverity notices dm_task_get_message_response() result should be
checked for NULL which should not be passed to dm_pool_strdup().
---
 WHATS_NEW_DM        |    1 +
 libdm/libdm-stats.c |    6 +++++-
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index c735194..795776b 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
 Version 1.02.111 - 
 ====================================
+  Test dm_task_get_message_response for !NULL in dm_stats_print_region().
   Add checks for failing dm_stats_create() in dmsetup.
   Add missing fifo close when failed to initialize client connection.
 
diff --git a/libdm/libdm-stats.c b/libdm/libdm-stats.c
index 43479d9..505b062 100644
--- a/libdm/libdm-stats.c
+++ b/libdm/libdm-stats.c
@@ -1259,6 +1259,7 @@ char *dm_stats_print_region(struct dm_stats *dms, uint64_t region_id,
 {
 	char *resp = NULL;
 	struct dm_task *dmt = NULL;
+	const char *response;
 
 	if (!_stats_bound(dms))
 		return_0;
@@ -1269,7 +1270,10 @@ char *dm_stats_print_region(struct dm_stats *dms, uint64_t region_id,
 	if (!dmt)
 		return_0;
 
-	resp = dm_pool_strdup(dms->mem, dm_task_get_message_response(dmt));
+	if (!(response = dm_task_get_message_response(dmt)))
+		return_0;
+
+	resp = dm_pool_strdup(dms->mem, response);
 	dm_task_destroy(dmt);
 
 	if (!resp)



                 reply	other threads:[~2015-11-09  9:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151109092831.0654960CD3@fedorahosted.org \
    --to=zkabelac@fedoraproject.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.