Blob Blame History Raw
From a6fb363020205d0c3d361bb10cf7df6ba8f28406 Mon Sep 17 00:00:00 2001
From: John Fastabend <john.r.fastabend@intel.com>
Date: Wed, 6 Apr 2011 08:48:24 -0700
Subject: [PATCH 46/51] lldpad: cleanup, fix check in gettlv for null ptr tlvs

Move check for null tlvs data structure in dcbx_gettlv()
above free tlvs. If there are no tlvs there is no reason
to try and free them.

Fortunantly, the free tlvs routines also check for a
null ptr so no harm is caused by doing this. But this
cleanup makes it read a bit better.

Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Signed-off-by: Petr Sabata <psabata@redhat.com>
---
 lldp_dcbx.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/lldp_dcbx.c b/lldp_dcbx.c
index 02c07f3..567f04e 100644
--- a/lldp_dcbx.c
+++ b/lldp_dcbx.c
@@ -296,13 +296,12 @@ struct packed_tlv* dcbx_gettlv(struct port *port)
 		return NULL;
 
 	tlvs = dcbx_data(port->ifname);
-
-	dcbx_free_tlv(tlvs);
 	if (!tlvs)
 		return NULL;
 
-	dcbx_bld_tlv(port);
+	dcbx_free_tlv(tlvs);
 
+	dcbx_bld_tlv(port);
 	if (tlvs->dcbx_st == dcbx_subtype2) {
 		/* Load Type127 - dcbx subtype 2*/
 		if (tlv_ok(tlvs->dcbx2))
-- 
1.7.4.4