Skip to contentSkip to conversation

synclink_gt fix module reference

PATCH New Paul Fulghum 1 participant 1 message Aug 14, 2007 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 synclink_gt fix module reference

Get module reference on open() by generic HDLC
to prevent module from unloading while interface
is active.

drivers/char/synclink_gt.c +4 -0
@@ -1570,6 +1570,9 @@ static int hdlcdev_open(struct net_devic
 	int rc;
 	unsigned long flags;
 
+	if (!try_module_get(THIS_MODULE))
+		return -EBUSY;
+
 	DBGINFO(("%s hdlcdev_open\n", dev->name));
 
 	/* generic HDLC layer open processing */
@@ -1639,6 +1642,7 @@ static int hdlcdev_close(struct net_devi
 	info->netcount=0;
 	spin_unlock_irqrestore(&info->netlock, flags);
 
+	module_put(THIS_MODULE);
 	return 0;
 }