From 194a3932ae14eca1c3b7ad37741de9f319d34da4 Mon Sep 17 00:00:00 2001
From: Kozlov Dmitry <dima@server>
Date: Wed, 6 Oct 2010 17:32:14 +0400
Subject: forgotten rcu_dereference

---
 driver/CMakeLists.txt |  6 +++---
 driver/pptp.c         | 10 ++++++++--
 2 files changed, 11 insertions(+), 5 deletions(-)

(limited to 'driver')

diff --git a/driver/CMakeLists.txt b/driver/CMakeLists.txt
index e9d511a..1daeb08 100644
--- a/driver/CMakeLists.txt
+++ b/driver/CMakeLists.txt
@@ -3,11 +3,11 @@ if (NOT DEFINED KDIR)
 endif (NOT DEFINED KDIR)
 
 ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/driver/pptp.ko
-	COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/driver &> /dev/null
+	COMMAND rm -rf ${CMAKE_CURRENT_BINARY_DIR}/driver
+	COMMAND mkdir ${CMAKE_CURRENT_BINARY_DIR}/driver
 	COMMAND ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/* ${CMAKE_CURRENT_BINARY_DIR}/driver
 	COMMAND make -C ${KDIR} M=${CMAKE_CURRENT_BINARY_DIR}/driver modules
-#	COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/pptp.ko ${CMAKE_CURRENT_BINARY_DIR}/pptp.ko
-#	COMMAND make -C ${KDIR} M=${CMAKE_CURRENT_SOURCE_DIR} clean
+	DEPENDS pptp.c
 )
 
 ADD_CUSTOM_TARGET(pptp_drv ALL
diff --git a/driver/pptp.c b/driver/pptp.c
index 696d407..58eb307 100644
--- a/driver/pptp.c
+++ b/driver/pptp.c
@@ -50,7 +50,7 @@
 #include "gre.h"
 #endif
 
-#define PPTP_DRIVER_VERSION "0.8.5-rc1"
+#define PPTP_DRIVER_VERSION "0.8.5"
 
 static int log_level=0;
 static int log_packets=10;
@@ -274,7 +274,13 @@ static int lookup_chan_dst(u16 call_id, __be32 d_addr)
 #endif
 	for(i = find_next_bit(callid_bitmap,MAX_CALLID,1); i < MAX_CALLID; 
 	                i = find_next_bit(callid_bitmap, MAX_CALLID, i + 1)){
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
+	    sock = rcu_dereference(callid_sock[i]);
+#else
 	    sock = callid_sock[i];
+#endif
+	    if (!sock)
+		continue;
 	    opt = &sock->proto.pptp;
 	    if (opt->dst_addr.call_id == call_id && opt->dst_addr.sin_addr.s_addr == d_addr) break;
 	}
@@ -308,12 +314,12 @@ static int add_chan(struct pppox_sock *sock)
 	else if (test_bit(sock->proto.pptp.src_addr.call_id,callid_bitmap))
 		goto exit;
 	
-	set_bit(sock->proto.pptp.src_addr.call_id,callid_bitmap);
 #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
 	rcu_assign_pointer(callid_sock[sock->proto.pptp.src_addr.call_id],sock);
 #else
 	callid_sock[sock->proto.pptp.src_addr.call_id] = sock;
 #endif
+	set_bit(sock->proto.pptp.src_addr.call_id,callid_bitmap);
 	res=0;
 
 exit:	
-- 
cgit v1.2.3