[Open-FCoE] [PATCH] libhbalinux: Segmentation fault in sa_table_search

Steve Ma steve.ma at intel.com
Wed Jul 1 23:31:24 UTC 2009


Checking for null pointer 'ep' should be done before passing
into the match fucntion.

Signed-off-by: Steve Ma <steve.ma at intel.com>
---

 utils.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/utils.c b/utils.c
index cc5c655..3a5666b 100644
--- a/utils.c
+++ b/utils.c
@@ -339,9 +339,11 @@ sa_table_search(struct sa_table *tp, void *(*match)(void *ep, void *arg),
 
 	for (i = 0; i < tp->st_limit; i++) {
 		ep = tp->st_table[i];
-		found = (*match)(ep, arg);
-		if (ep != NULL && found != NULL)
-			break;
+		if (ep != NULL) {
+			found = (*match)(ep, arg);
+			if (found != NULL)
+				break;
+		}
 	}
 	return found;
 }




More information about the devel mailing list