diff --git a/src/knot/server/zones.c b/src/knot/server/zones.c
index 4bf4a20be9a35f34040e5541ffad11fa754ae526..b7132cc4436f5179e76215e405b4b1ecc42d7d4c 100644
--- a/src/knot/server/zones.c
+++ b/src/knot/server/zones.c
@@ -2639,12 +2639,12 @@ int zones_save_zone(const knot_ns_xfr_t *xfr)
 {
 	/* Zone is already referenced, no need for RCU locking. */
 
-	dbg_xfr("xfr: %s Saving new zone file.\n", xfr->msg);
-
 	if (xfr == NULL || xfr->new_contents == NULL || xfr->zone == NULL) {
 		return KNOT_EINVAL;
 	}
 
+	dbg_xfr("xfr: %s Saving new zone file.\n", xfr->msg);
+
 	zonedata_t *zd = (zonedata_t *)knot_zone_data(xfr->zone);
 	knot_zone_contents_t *new_zone = xfr->new_contents;