diff options
author | Johannes Stezenbach <devnull@localhost> | 2004-12-13 13:34:55 +0000 |
---|---|---|
committer | Johannes Stezenbach <devnull@localhost> | 2004-12-13 13:34:55 +0000 |
commit | 67f890d8c41c18f014b67fc1e08c9ebcd67023f8 (patch) | |
tree | 70be450cf128167f5a117288eb12c9932bc5713b /linux/drivers | |
parent | 2fc80f99b84cee7806ea512b956b978dd03d8fb0 (diff) | |
download | mediapointer-dvb-s2-67f890d8c41c18f014b67fc1e08c9ebcd67023f8.tar.gz mediapointer-dvb-s2-67f890d8c41c18f014b67fc1e08c9ebcd67023f8.tar.bz2 |
add error checking for NET_REMOVE_IF to prevent Oops when
calling dvbnet -d N for an invalid interface number;
based on patch by Emard
Diffstat (limited to 'linux/drivers')
-rw-r--r-- | linux/drivers/media/dvb/dvb-core/dvb_net.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_net.c b/linux/drivers/media/dvb/dvb-core/dvb_net.c index 3609dba2b..707ad80ab 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_net.c +++ b/linux/drivers/media/dvb/dvb-core/dvb_net.c @@ -1198,13 +1198,14 @@ static int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid, u8 feedtype) return if_num; } -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; @@ -1265,10 +1266,18 @@ static int dvb_net_do_ioctl(struct inode *inode, struct file *file, 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: |