Skip to contentSkip to conversation

fix dvb-net Oops

PATCH New Johannes Stezenbach 1 participant 1 message Dec 13, 2004 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix dvb-net Oops

Hi,

emard<at>softhome!net discovered an embarrasing bug in dvb_net.c where the NET_REMOVE_IF ioctl will cause an Oops when called with an invalid interface number.

The patch applies on top of the other dvb patches in linux-2.6.10-rc3-mm1 and should go into 2.6.10.

Johannes

drivers/media/dvb/dvb-core/dvb_net.c renamed from drivers/media/dvb/dvb-core/dvb_net.c.orig +13 -4
@@ -1201,13 +1201,14 @@ static int dvb_net_add_if(struct dvb_net
 }
 
 
-static int dvb_net_remove_if(struct dvb_net *dvbnet, int num)
+static int dvb_net_remove_if(struct dvb_net *dvbnet, unsigned int num)
 {
 	struct net_device *net = dvbnet->device[num];
-	struct dvb_net_priv *priv = net->priv;
+	struct dvb_net_priv *priv;
 
 	if (!dvbnet->state[num])
 		return -EINVAL;
+	priv = net->priv;
 	if (priv->in_use)
 		return -EBUSY;
 
@@ -1268,10 +1269,18 @@ static int dvb_net_do_ioctl(struct inode
 		break;
 	}
 	case NET_REMOVE_IF:
+	{
+		int ret;
+
 		if (!capable(CAP_SYS_ADMIN))
 			return -EPERM;
-		module_put(dvbdev->adapter->module);
-		return dvb_net_remove_if(dvbnet, (int) (long) parg);
+		if ((unsigned int) parg >= DVB_NET_DEVICES_MAX)
+			return -EINVAL;
+		ret = dvb_net_remove_if(dvbnet, (unsigned int) parg);
+		if (!ret)
+			module_put(dvbdev->adapter->module);
+		return ret;
+	}
 
 	/* binary compatiblity cruft */
 	case __NET_ADD_IF_OLD: