Commit 54064600 authored by Alan Cox's avatar Alan Cox Committed by David S. Miller

irda: Push BKL down into irda ioctl handlers

Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 866988ed
...@@ -628,8 +628,8 @@ dev_irnet_poll(struct file * file, ...@@ -628,8 +628,8 @@ dev_irnet_poll(struct file * file,
* This is the way pppd configure us and control us while the PPP * This is the way pppd configure us and control us while the PPP
* instance is active. * instance is active.
*/ */
static int static long
dev_irnet_ioctl(struct inode * inode, dev_irnet_ioctl(
struct file * file, struct file * file,
unsigned int cmd, unsigned int cmd,
unsigned long arg) unsigned long arg)
...@@ -660,6 +660,7 @@ dev_irnet_ioctl(struct inode * inode, ...@@ -660,6 +660,7 @@ dev_irnet_ioctl(struct inode * inode,
{ {
DEBUG(FS_INFO, "Entering PPP discipline.\n"); DEBUG(FS_INFO, "Entering PPP discipline.\n");
/* PPP channel setup (ap->chan in configued in dev_irnet_open())*/ /* PPP channel setup (ap->chan in configued in dev_irnet_open())*/
lock_kernel();
err = ppp_register_channel(&ap->chan); err = ppp_register_channel(&ap->chan);
if(err == 0) if(err == 0)
{ {
...@@ -672,12 +673,14 @@ dev_irnet_ioctl(struct inode * inode, ...@@ -672,12 +673,14 @@ dev_irnet_ioctl(struct inode * inode,
} }
else else
DERROR(FS_ERROR, "Can't setup PPP channel...\n"); DERROR(FS_ERROR, "Can't setup PPP channel...\n");
unlock_kernel();
} }
else else
{ {
/* In theory, should be N_TTY */ /* In theory, should be N_TTY */
DEBUG(FS_INFO, "Exiting PPP discipline.\n"); DEBUG(FS_INFO, "Exiting PPP discipline.\n");
/* Disconnect from the generic PPP layer */ /* Disconnect from the generic PPP layer */
lock_kernel();
if(ap->ppp_open) if(ap->ppp_open)
{ {
ap->ppp_open = 0; ap->ppp_open = 0;
...@@ -686,24 +689,20 @@ dev_irnet_ioctl(struct inode * inode, ...@@ -686,24 +689,20 @@ dev_irnet_ioctl(struct inode * inode,
else else
DERROR(FS_ERROR, "Channel not registered !\n"); DERROR(FS_ERROR, "Channel not registered !\n");
err = 0; err = 0;
unlock_kernel();
} }
break; break;
/* Query PPP channel and unit number */ /* Query PPP channel and unit number */
case PPPIOCGCHAN: case PPPIOCGCHAN:
if(!ap->ppp_open) if(ap->ppp_open && !put_user(ppp_channel_index(&ap->chan),
break; (int __user *)argp))
if(put_user(ppp_channel_index(&ap->chan), (int __user *)argp))
break;
DEBUG(FS_INFO, "Query channel.\n");
err = 0; err = 0;
break; break;
case PPPIOCGUNIT: case PPPIOCGUNIT:
if(!ap->ppp_open) lock_kernel();
break; if(ap->ppp_open && !put_user(ppp_unit_number(&ap->chan),
if(put_user(ppp_unit_number(&ap->chan), (int __user *)argp)) (int __user *)argp))
break;
DEBUG(FS_INFO, "Query unit number.\n");
err = 0; err = 0;
break; break;
...@@ -723,34 +722,39 @@ dev_irnet_ioctl(struct inode * inode, ...@@ -723,34 +722,39 @@ dev_irnet_ioctl(struct inode * inode,
DEBUG(FS_INFO, "Standard PPP ioctl.\n"); DEBUG(FS_INFO, "Standard PPP ioctl.\n");
if(!capable(CAP_NET_ADMIN)) if(!capable(CAP_NET_ADMIN))
err = -EPERM; err = -EPERM;
else else {
lock_kernel();
err = ppp_irnet_ioctl(&ap->chan, cmd, arg); err = ppp_irnet_ioctl(&ap->chan, cmd, arg);
unlock_kernel();
}
break; break;
/* TTY IOCTLs : Pretend that we are a tty, to keep pppd happy */ /* TTY IOCTLs : Pretend that we are a tty, to keep pppd happy */
/* Get termios */ /* Get termios */
case TCGETS: case TCGETS:
DEBUG(FS_INFO, "Get termios.\n"); DEBUG(FS_INFO, "Get termios.\n");
lock_kernel();
#ifndef TCGETS2 #ifndef TCGETS2
if(kernel_termios_to_user_termios((struct termios __user *)argp, &ap->termios)) if(!kernel_termios_to_user_termios((struct termios __user *)argp, &ap->termios))
break; err = 0;
#else #else
if(kernel_termios_to_user_termios_1((struct termios __user *)argp, &ap->termios)) if(kernel_termios_to_user_termios_1((struct termios __user *)argp, &ap->termios))
break;
#endif
err = 0; err = 0;
#endif
unlock_kernel();
break; break;
/* Set termios */ /* Set termios */
case TCSETSF: case TCSETSF:
DEBUG(FS_INFO, "Set termios.\n"); DEBUG(FS_INFO, "Set termios.\n");
lock_kernel();
#ifndef TCGETS2 #ifndef TCGETS2
if(user_termios_to_kernel_termios(&ap->termios, (struct termios __user *)argp)) if(!user_termios_to_kernel_termios(&ap->termios, (struct termios __user *)argp))
break; err = 0;
#else #else
if(user_termios_to_kernel_termios_1(&ap->termios, (struct termios __user *)argp)) if(!user_termios_to_kernel_termios_1(&ap->termios, (struct termios __user *)argp))
break;
#endif
err = 0; err = 0;
#endif
unlock_kernel();
break; break;
/* Set DTR/RTS */ /* Set DTR/RTS */
...@@ -773,7 +777,9 @@ dev_irnet_ioctl(struct inode * inode, ...@@ -773,7 +777,9 @@ dev_irnet_ioctl(struct inode * inode,
* We should also worry that we don't accept junk here and that * We should also worry that we don't accept junk here and that
* we get rid of our own buffers */ * we get rid of our own buffers */
#ifdef FLUSH_TO_PPP #ifdef FLUSH_TO_PPP
lock_kernel();
ppp_output_wakeup(&ap->chan); ppp_output_wakeup(&ap->chan);
unlock_kernel();
#endif /* FLUSH_TO_PPP */ #endif /* FLUSH_TO_PPP */
err = 0; err = 0;
break; break;
...@@ -788,7 +794,7 @@ dev_irnet_ioctl(struct inode * inode, ...@@ -788,7 +794,7 @@ dev_irnet_ioctl(struct inode * inode,
default: default:
DERROR(FS_ERROR, "Unsupported ioctl (0x%X)\n", cmd); DERROR(FS_ERROR, "Unsupported ioctl (0x%X)\n", cmd);
err = -ENOIOCTLCMD; err = -ENOTTY;
} }
DEXIT(FS_TRACE, " - err = 0x%X\n", err); DEXIT(FS_TRACE, " - err = 0x%X\n", err);
......
...@@ -76,9 +76,8 @@ static ssize_t ...@@ -76,9 +76,8 @@ static ssize_t
static unsigned int static unsigned int
dev_irnet_poll(struct file *, dev_irnet_poll(struct file *,
poll_table *); poll_table *);
static int static long
dev_irnet_ioctl(struct inode *, dev_irnet_ioctl(struct file *,
struct file *,
unsigned int, unsigned int,
unsigned long); unsigned long);
/* ------------------------ PPP INTERFACE ------------------------ */ /* ------------------------ PPP INTERFACE ------------------------ */
...@@ -102,7 +101,7 @@ static struct file_operations irnet_device_fops = ...@@ -102,7 +101,7 @@ static struct file_operations irnet_device_fops =
.read = dev_irnet_read, .read = dev_irnet_read,
.write = dev_irnet_write, .write = dev_irnet_write,
.poll = dev_irnet_poll, .poll = dev_irnet_poll,
.ioctl = dev_irnet_ioctl, .unlocked_ioctl = dev_irnet_ioctl,
.open = dev_irnet_open, .open = dev_irnet_open,
.release = dev_irnet_close .release = dev_irnet_close
/* Also : llseek, readdir, mmap, flush, fsync, fasync, lock, readv, writev */ /* Also : llseek, readdir, mmap, flush, fsync, fasync, lock, readv, writev */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment