[lvm-devel] [PATCH 08/30] Ensure first is not NULL

Zdenek Kabelac zkabelac at redhat.com
Mon Oct 25 08:24:15 UTC 2010


clang Logic error	Dereference of null pointer

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

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

diff --git a/lib/format1/format1.c b/lib/format1/format1.c
index 0dcec05..0efde31 100644
--- a/lib/format1/format1.c
+++ b/lib/format1/format1.c
@@ -103,7 +103,7 @@ static int _check_vgs(struct dm_list *pvs, struct volume_group *vg)
 	}
 
 	/* On entry to fn, list known to be non-empty */
-	if (pv_count != first->vgd.pv_cur) {
+	if (first && (pv_count != first->vgd.pv_cur)) {
 		log_error("%d PV(s) found for VG %s: expected %d",
 			  pv_count, first->pvd.vg_name, first->vgd.pv_cur);
 		vg->status |= PARTIAL_VG;
-- 
1.7.3.1




More information about the lvm-devel mailing list