[stgt] [PATCH] added safety checks for the logarea pointer

Alexander Nezhinsky alexandern at voltaire.com
Tue Jun 15 16:56:40 CEST 2010


resending the patch, with pointer initialization removed, as requested

Signed-off-by: Alexander Nezhinsky <alexandern at voltaire.com>
---
diff --git a/usr/log.c b/usr/log.c
index 305e14f..be9b0c2 100644
--- a/usr/log.c
+++ b/usr/log.c
@@ -131,10 +131,13 @@ static int logarea_init (int size)

 static void free_logarea (void)
 {
+	if (!la)
+		return;
 	semctl(la->semid, 0, IPC_RMID, la->semarg);
 	shmdt(la->buff);
 	shmdt(la->start);
 	shmdt(la);
+	la = NULL;
 }

 #if LOGDBG
@@ -308,6 +311,9 @@ static void log_flush(void)
 {
 	struct sembuf ops;

+	if (!la)
+		return;
+
 	while (!la->empty) {
 		ops.sem_num = 0;
 		ops.sem_flg = 0;
-- 
1.6.5

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list