[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] [PATCH 3/5] Ensure first is not NULL before dereference



clang Logic error Dereference of null pointer

For empty lists make sure the NULL first pointer is not dereferenced
and report error.

Signed-off-by: Zdenek Kabelac <zkabelac redhat com>
---
 lib/format1/format1.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/lib/format1/format1.c b/lib/format1/format1.c
index 0dcec05..c5685c9 100644
--- a/lib/format1/format1.c
+++ b/lib/format1/format1.c
@@ -102,6 +102,11 @@ static int _check_vgs(struct dm_list *pvs, struct volume_group *vg)
 		pv_count++;
 	}
 
+	if (!first) {
+		log_error(INTERNAL_ERROR "Unexpected empty PV list.");
+		return 0;
+	}
+
 	/* On entry to fn, list known to be non-empty */
 	if (pv_count != first->vgd.pv_cur) {
 		log_error("%d PV(s) found for VG %s: expected %d",
-- 
1.7.3.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]