From ecc38983f6c83f371fefb5a69a72e358fc7b1218 Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Thu, 15 May 2008 10:46:49 -0600 Subject: ipmi: cdev lock_kernel() pushdown Signed-off-by: Jonathan Corbet --- drivers/char/ipmi/ipmi_devintf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c index 0246a2b8ce4..c816656d6bf 100644 --- a/drivers/char/ipmi/ipmi_devintf.c +++ b/drivers/char/ipmi/ipmi_devintf.c @@ -43,6 +43,7 @@ #include #include #include +#include struct ipmi_file_private { @@ -121,6 +122,7 @@ static int ipmi_open(struct inode *inode, struct file *file) if (!priv) return -ENOMEM; + lock_kernel(); priv->file = file; rv = ipmi_create_user(if_num, @@ -129,7 +131,7 @@ static int ipmi_open(struct inode *inode, struct file *file) &(priv->user)); if (rv) { kfree(priv); - return rv; + goto out; } file->private_data = priv; @@ -144,7 +146,9 @@ static int ipmi_open(struct inode *inode, struct file *file) priv->default_retries = -1; priv->default_retry_time_ms = 0; - return 0; +out: + unlock_kernel(); + return rv; } static int ipmi_release(struct inode *inode, struct file *file) -- cgit v1.2.3 From 1f439647a4072ec64bb2e4b9290cd7be6aee8328 Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Thu, 15 May 2008 11:04:19 -0600 Subject: mem: cdev lock_kernel() pushdown It's really hard to tell if this is necessary - lots of weird magic happens by way of map_devmem() Signed-off-by: Jonathan Corbet --- drivers/char/mem.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 934ffafedae..070e22e8ea9 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -889,6 +890,9 @@ static const struct file_operations kmsg_fops = { static int memory_open(struct inode * inode, struct file * filp) { + int ret = 0; + + lock_kernel(); switch (iminor(inode)) { case 1: filp->f_op = &mem_fops; @@ -932,11 +936,13 @@ static int memory_open(struct inode * inode, struct file * filp) break; #endif default: + unlock_kernel(); return -ENXIO; } if (filp->f_op && filp->f_op->open) - return filp->f_op->open(inode,filp); - return 0; + ret = filp->f_op->open(inode,filp); + unlock_kernel(); + return ret; } static const struct file_operations memory_fops = { -- cgit v1.2.3 From 309c4551c0fa0897d5343c36cbfbfa39f1f41b88 Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Thu, 15 May 2008 11:07:52 -0600 Subject: misc: cdev lock_kernel() pushdown misc_open() looks fine, but who knows what all of the misc drivers are doing in their open() functions? Signed-off-by: Jonathan Corbet --- drivers/char/misc.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/misc.c b/drivers/char/misc.c index eaace0db0ff..6e1563c3d30 100644 --- a/drivers/char/misc.c +++ b/drivers/char/misc.c @@ -49,6 +49,7 @@ #include #include #include +#include /* * Head entry for the doubly linked miscdevice list @@ -118,6 +119,7 @@ static int misc_open(struct inode * inode, struct file * file) int err = -ENODEV; const struct file_operations *old_fops, *new_fops = NULL; + lock_kernel(); mutex_lock(&misc_mtx); list_for_each_entry(c, &misc_list, list) { @@ -155,6 +157,7 @@ static int misc_open(struct inode * inode, struct file * file) fops_put(old_fops); fail: mutex_unlock(&misc_mtx); + unlock_kernel(); return err; } -- cgit v1.2.3 From 2d863e92ec1b1deb8167d7f5266f754f258e876a Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Thu, 15 May 2008 11:16:21 -0600 Subject: viotape: cdev lock_kernel pushdown () Signed-off-by: Jonathan Corbet --- drivers/char/viotape.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c index 58aad63831f..af03d270930 100644 --- a/drivers/char/viotape.c +++ b/drivers/char/viotape.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -687,6 +688,7 @@ static int viotap_open(struct inode *inode, struct file *file) if (op == NULL) return -ENOMEM; + lock_kernel() get_dev_info(file->f_path.dentry->d_inode, &devi); /* Note: We currently only support one mode! */ @@ -717,6 +719,7 @@ static int viotap_open(struct inode *inode, struct file *file) free_op: free_op_struct(op); + unlock_kernel(); return ret; } -- cgit v1.2.3 From 12ead6b098b65dd21d3ed4fcccf20025dbe86cc2 Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Thu, 15 May 2008 11:24:23 -0600 Subject: mbcs: cdev lock_kernel() pushdown This driver would appear to have no internal locking at all. Signed-off-by: Jonathan Corbet --- drivers/char/mbcs.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/mbcs.c b/drivers/char/mbcs.c index f4716ad7348..acd8e9ed474 100644 --- a/drivers/char/mbcs.c +++ b/drivers/char/mbcs.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -382,15 +383,19 @@ static int mbcs_open(struct inode *ip, struct file *fp) struct mbcs_soft *soft; int minor; + lock_kernel(); minor = iminor(ip); + /* Nothing protects access to this list... */ list_for_each_entry(soft, &soft_list, list) { if (soft->nasid == minor) { fp->private_data = soft->cxdev; + unlock_kernel(); return 0; } } + unlock_kernel(); return -ENODEV; } -- cgit v1.2.3 From abedd296e97a5d943e76999de97253f1b62a4846 Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Thu, 15 May 2008 11:29:38 -0600 Subject: lp: cdev lock_kernel() pushdown Signed-off-by: Jonathan Corbet --- drivers/char/lp.c | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/lp.c b/drivers/char/lp.c index 60ac642752b..71abb4c33aa 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c @@ -126,6 +126,7 @@ #include #include #include +#include #include #undef LP_STATS @@ -489,14 +490,21 @@ static ssize_t lp_read(struct file * file, char __user * buf, static int lp_open(struct inode * inode, struct file * file) { unsigned int minor = iminor(inode); + int ret = 0; - if (minor >= LP_NO) - return -ENXIO; - if ((LP_F(minor) & LP_EXIST) == 0) - return -ENXIO; - if (test_and_set_bit(LP_BUSY_BIT_POS, &LP_F(minor))) - return -EBUSY; - + lock_kernel(); + if (minor >= LP_NO) { + ret = -ENXIO; + goto out; + } + if ((LP_F(minor) & LP_EXIST) == 0) { + ret = -ENXIO; + goto out; + } + if (test_and_set_bit(LP_BUSY_BIT_POS, &LP_F(minor))) { + ret = -EBUSY; + goto out; + } /* If ABORTOPEN is set and the printer is offline or out of paper, we may still want to open it to perform ioctl()s. Therefore we have commandeered O_NONBLOCK, even though it is being used in @@ -510,21 +518,25 @@ static int lp_open(struct inode * inode, struct file * file) if (status & LP_POUTPA) { printk(KERN_INFO "lp%d out of paper\n", minor); LP_F(minor) &= ~LP_BUSY; - return -ENOSPC; + ret = -ENOSPC; + goto out; } else if (!(status & LP_PSELECD)) { printk(KERN_INFO "lp%d off-line\n", minor); LP_F(minor) &= ~LP_BUSY; - return -EIO; + ret = -EIO; + goto out; } else if (!(status & LP_PERRORP)) { printk(KERN_ERR "lp%d printer error\n", minor); LP_F(minor) &= ~LP_BUSY; - return -EIO; + ret = -EIO; + goto out; } } lp_table[minor].lp_buffer = kmalloc(LP_BUFFER_SIZE, GFP_KERNEL); if (!lp_table[minor].lp_buffer) { LP_F(minor) &= ~LP_BUSY; - return -ENOMEM; + ret = -ENOMEM; + goto out; } /* Determine if the peripheral supports ECP mode */ lp_claim_parport_or_block (&lp_table[minor]); @@ -540,7 +552,9 @@ static int lp_open(struct inode * inode, struct file * file) parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); lp_release_parport (&lp_table[minor]); lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; - return 0; +out: + unlock_kernel(); + return ret; } static int lp_release(struct inode * inode, struct file * file) -- cgit v1.2.3 From 70ffa16e604bab22b12bf72cb7796f1dd01ec335 Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Thu, 15 May 2008 11:34:16 -0600 Subject: drm: cdev lock_kernel() pushdown Signed-off-by: Jonathan Corbet --- drivers/char/drm/drm_fops.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/drm/drm_fops.c b/drivers/char/drm/drm_fops.c index 68f0da801ed..7a25726f07f 100644 --- a/drivers/char/drm/drm_fops.c +++ b/drivers/char/drm/drm_fops.c @@ -37,6 +37,7 @@ #include "drmP.h" #include "drm_sarea.h" #include +#include static int drm_open_helper(struct inode *inode, struct file *filp, struct drm_device * dev); @@ -174,12 +175,14 @@ int drm_stub_open(struct inode *inode, struct file *filp) DRM_DEBUG("\n"); + /* BKL pushdown: note that nothing else serializes idr_find() */ + lock_kernel(); minor = idr_find(&drm_minors_idr, minor_id); if (!minor) - return -ENODEV; + goto out; if (!(dev = minor->dev)) - return -ENODEV; + goto out; old_fops = filp->f_op; filp->f_op = fops_get(&dev->driver->fops); @@ -189,6 +192,8 @@ int drm_stub_open(struct inode *inode, struct file *filp) } fops_put(old_fops); +out: + unlock_kernel(); return err; } -- cgit v1.2.3 From c43ef17450dce8cbf50f97497a1949ff8f484e88 Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Thu, 15 May 2008 16:44:14 -0600 Subject: snsc: cdev lock_kernel() pushdown Signed-off-by: Jonathan Corbet --- drivers/char/snsc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'drivers/char') diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c index 8fe099a4106..0b799ac1b04 100644 --- a/drivers/char/snsc.c +++ b/drivers/char/snsc.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -104,6 +105,7 @@ scdrv_open(struct inode *inode, struct file *file) file->private_data = sd; /* hook this subchannel up to the system controller interrupt */ + lock_kernel(); rv = request_irq(SGI_UART_VECTOR, scdrv_interrupt, IRQF_SHARED | IRQF_DISABLED, SYSCTL_BASENAME, sd); @@ -111,9 +113,10 @@ scdrv_open(struct inode *inode, struct file *file) ia64_sn_irtr_close(sd->sd_nasid, sd->sd_subch); kfree(sd); printk("%s: irq request failed (%d)\n", __func__, rv); + unlock_kernel(); return -EBUSY; } - + unlock_kernel(); return 0; } -- cgit v1.2.3 From 39d95b9d857ad9ed335dd1a2d6c6de1f1ee69ce1 Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Fri, 16 May 2008 09:10:50 -0600 Subject: tty: cdev lock_kernel() pushdown Parts of the serial code actually BUG() if we don't do this. --- drivers/char/tty_io.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index e94bee03231..fd182f2e4a6 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -2665,7 +2665,7 @@ static void release_dev(struct file *filp) * ->siglock protects ->signal/->sighand */ -static int tty_open(struct inode *inode, struct file *filp) +static int __tty_open(struct inode *inode, struct file *filp) { struct tty_struct *tty; int noctty, retval; @@ -2779,6 +2779,19 @@ got_driver: return 0; } +/* BKL pushdown: scary code avoidance wrapper */ +static int tty_open(struct inode *inode, struct file *filp) +{ + int ret; + + lock_kernel(); + ret = __tty_open(inode, filp); + unlock_kernel(); + return ret; +} + + + #ifdef CONFIG_UNIX98_PTYS /** * ptmx_open - open a unix 98 pty master @@ -2792,7 +2805,7 @@ got_driver: * allocated_ptys_lock handles the list of free pty numbers */ -static int ptmx_open(struct inode *inode, struct file *filp) +static int __ptmx_open(struct inode *inode, struct file *filp) { struct tty_struct *tty; int retval; @@ -2831,6 +2844,16 @@ out: devpts_kill_index(index); return retval; } + +static int ptmx_open(struct inode *inode, struct file *filp) +{ + int ret; + + lock_kernel(); + ret = __ptmx_open(inode, filp); + unlock_kernel(); + return ret; +} #endif /** -- cgit v1.2.3 From d21c95c569c462da20d491b75d0a45bd70ddc1bf Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Fri, 16 May 2008 13:40:30 -0600 Subject: Add "no BKL needed" comments to several drivers This documents the fact that somebody looked at the relevant open() functions and concluded that, due to their trivial nature, no locking was needed. Signed-off-by: Jonathan Corbet --- drivers/char/cs5535_gpio.c | 2 ++ drivers/char/dtlk.c | 2 ++ drivers/char/pc8736x_gpio.c | 1 + drivers/char/ppdev.c | 1 + drivers/char/scx200_gpio.c | 1 + drivers/char/tb0219.c | 1 + drivers/char/vr41xx_giu.c | 2 ++ 7 files changed, 10 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/cs5535_gpio.c b/drivers/char/cs5535_gpio.c index c0a4a0bb509..628e3d3249d 100644 --- a/drivers/char/cs5535_gpio.c +++ b/drivers/char/cs5535_gpio.c @@ -153,6 +153,8 @@ static ssize_t cs5535_gpio_read(struct file *file, char __user *buf, return count; } +/* No BKL needed here - "mask" is the only global resource used + here and it's a boot-time parameter */ static int cs5535_gpio_open(struct inode *inode, struct file *file) { u32 m = iminor(inode); diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c index abde6ddefe6..433388c6023 100644 --- a/drivers/char/dtlk.c +++ b/drivers/char/dtlk.c @@ -288,6 +288,8 @@ static int dtlk_ioctl(struct inode *inode, } } +/* No BKL needed here; "dtlk_busy" is the only global resource, + and it is not ever set by anybody (test is broken) */ static int dtlk_open(struct inode *inode, struct file *file) { TRACE_TEXT("(dtlk_open"); diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c index ecfaf180e5b..8715dc9f4a5 100644 --- a/drivers/char/pc8736x_gpio.c +++ b/drivers/char/pc8736x_gpio.c @@ -212,6 +212,7 @@ static struct nsc_gpio_ops pc8736x_gpio_ops = { .gpio_current = pc8736x_gpio_current }; +/* No BKL needed here; no global resources accessed */ static int pc8736x_gpio_open(struct inode *inode, struct file *file) { unsigned m = iminor(inode); diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c index 3aab837d948..ce198757488 100644 --- a/drivers/char/ppdev.c +++ b/drivers/char/ppdev.c @@ -633,6 +633,7 @@ static int pp_ioctl(struct inode *inode, struct file *file, return 0; } +/* No BKL needed here: only local resources used */ static int pp_open (struct inode * inode, struct file * file) { unsigned int minor = iminor(inode); diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c index 99e5272e3c5..be2c623a986 100644 --- a/drivers/char/scx200_gpio.c +++ b/drivers/char/scx200_gpio.c @@ -46,6 +46,7 @@ struct nsc_gpio_ops scx200_gpio_ops = { }; EXPORT_SYMBOL_GPL(scx200_gpio_ops); +/* No BKL needed here: no global resources used */ static int scx200_gpio_open(struct inode *inode, struct file *file) { unsigned m = iminor(inode); diff --git a/drivers/char/tb0219.c b/drivers/char/tb0219.c index 4c431cb7cf1..db8c2ca2ce4 100644 --- a/drivers/char/tb0219.c +++ b/drivers/char/tb0219.c @@ -232,6 +232,7 @@ static ssize_t tanbac_tb0219_write(struct file *file, const char __user *data, return i; } +/* No BKL needed here; no global resources accessed */ static int tanbac_tb0219_open(struct inode *inode, struct file *file) { unsigned int minor; diff --git a/drivers/char/vr41xx_giu.c b/drivers/char/vr41xx_giu.c index e5ed09192be..412937fdb95 100644 --- a/drivers/char/vr41xx_giu.c +++ b/drivers/char/vr41xx_giu.c @@ -543,6 +543,8 @@ static ssize_t gpio_write(struct file *file, const char __user *data, return i; } +/* No BKL needed here; only global (giu_nr_pins) is only set + at probe time */ static int gpio_open(struct inode *inode, struct file *file) { unsigned int pin; -- cgit v1.2.3 From f97259e35de1f99ba0ac19383408e247fd763cf0 Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Fri, 16 May 2008 13:47:50 -0600 Subject: vcs: BKL pushdown Add explicit BKL to vcs_open(). Signed-off-by: Jonathan Corbet --- drivers/char/vc_screen.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c index 83aeedda200..eebfad2777d 100644 --- a/drivers/char/vc_screen.c +++ b/drivers/char/vc_screen.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -460,9 +461,13 @@ static int vcs_open(struct inode *inode, struct file *filp) { unsigned int currcons = iminor(inode) & 127; + int ret = 0; + + lock_kernel(); if(currcons && !vc_cons_allocated(currcons-1)) - return -ENXIO; - return 0; + ret = -ENXIO; + unlock_kernel(); + return ret; } static const struct file_operations vcs_fops = { -- cgit v1.2.3 From f4943db14f5071ecbf7ca76722e59a2fd22bda4d Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Fri, 16 May 2008 13:50:20 -0600 Subject: xilinx icap: BKL pushdown Add explicit lock_kernel() calls to hwicap_open() even though the existing locking looks adequate. Signed-off-by: Jonathan Corbet --- drivers/char/xilinx_hwicap/xilinx_hwicap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers/char') diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c index 3edf1fc1296..1e1b81e57cd 100644 --- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c +++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c @@ -85,6 +85,7 @@ #include #include #include +#include #include #include #include @@ -504,11 +505,12 @@ static int hwicap_open(struct inode *inode, struct file *file) struct hwicap_drvdata *drvdata; int status; + lock_kernel(); drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev); status = mutex_lock_interruptible(&drvdata->sem); if (status) - return status; + goto out; if (drvdata->is_open) { status = -EBUSY; @@ -528,6 +530,8 @@ static int hwicap_open(struct inode *inode, struct file *file) error: mutex_unlock(&drvdata->sem); + out: + unlock_kernel(); return status; } -- cgit v1.2.3 From b8c71d7ae2a7f723d171d9175212b6d0a727655d Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Fri, 16 May 2008 13:53:00 -0600 Subject: tlckl: BKL pushdown Put explicit lock_kernel calls into tlclk_open() Signed-off-by: Jonathan Corbet --- drivers/char/tlclk.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c index 35e58030d29..8f2284be68e 100644 --- a/drivers/char/tlclk.c +++ b/drivers/char/tlclk.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -204,11 +205,14 @@ static int tlclk_open(struct inode *inode, struct file *filp) { int result; - if (test_and_set_bit(0, &useflags)) - return -EBUSY; + lock_kernel(); + if (test_and_set_bit(0, &useflags)) { + result = -EBUSY; /* this legacy device is always one per system and it doesn't * know how to handle multiple concurrent clients. */ + goto out; + } /* Make sure there is no interrupt pending while * initialising interrupt handler */ @@ -218,13 +222,14 @@ static int tlclk_open(struct inode *inode, struct file *filp) * we can't share this IRQ */ result = request_irq(telclk_interrupt, &tlclk_interrupt, IRQF_DISABLED, "telco_clock", tlclk_interrupt); - if (result == -EBUSY) { + if (result == -EBUSY) printk(KERN_ERR "tlclk: Interrupt can't be reserved.\n"); - return -EBUSY; - } - inb(TLCLK_REG6); /* Clear interrupt events */ + else + inb(TLCLK_REG6); /* Clear interrupt events */ - return 0; +out: + unlock_kernel(); + return result; } static int tlclk_release(struct inode *inode, struct file *filp) -- cgit v1.2.3 From c0bed680f0ca603864375ed5f9fed4296a53aa62 Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Fri, 16 May 2008 13:54:46 -0600 Subject: raw: BKL pushdown Put explicit lock_kernel() calls into raw_open(), even though the existing locking looks adequate. Signed-off-by: Jonathan Corbet --- drivers/char/raw.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/raw.c b/drivers/char/raw.c index bbfa0e241cb..505fcbe884a 100644 --- a/drivers/char/raw.c +++ b/drivers/char/raw.c @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -53,6 +54,7 @@ static int raw_open(struct inode *inode, struct file *filp) return 0; } + lock_kernel(); mutex_lock(&raw_mutex); /* @@ -79,6 +81,7 @@ static int raw_open(struct inode *inode, struct file *filp) bdev->bd_inode->i_mapping; filp->private_data = bdev; mutex_unlock(&raw_mutex); + unlock_kernel(); return 0; out2: -- cgit v1.2.3 From 65f37b790bd7ba15413838579470296a709c45e6 Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Fri, 16 May 2008 13:57:31 -0600 Subject: dsp56k: BKL pushdown Put explicit lock_kernel calls into dsp56k_open(). [Stupid missing label error fixed] Signed-off-by: Jonathan Corbet --- drivers/char/dsp56k.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c index a69c6528326..7bf7485377e 100644 --- a/drivers/char/dsp56k.c +++ b/drivers/char/dsp56k.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -436,13 +437,17 @@ static unsigned int dsp56k_poll(struct file *file, poll_table *wait) static int dsp56k_open(struct inode *inode, struct file *file) { int dev = iminor(inode) & 0x0f; + int ret = 0; + lock_kernel(); switch(dev) { case DSP56K_DEV_56001: - if (test_and_set_bit(0, &dsp56k.in_use)) - return -EBUSY; + if (test_and_set_bit(0, &dsp56k.in_use)) { + ret = -EBUSY; + goto out; + } dsp56k.timeout = TIMEOUT; dsp56k.maxio = MAXIO; @@ -458,10 +463,11 @@ static int dsp56k_open(struct inode *inode, struct file *file) break; default: - return -ENODEV; + ret = -ENODEV; } - - return 0; +out: + unlock_kernel(); + return ret; } static int dsp56k_release(struct inode *inode, struct file *file) -- cgit v1.2.3 From f2b9857eee17797541b845782ade4d7a9d50f843 Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Sun, 18 May 2008 15:32:43 -0600 Subject: Add a bunch of cycle_kernel_lock() calls All of the open() functions which don't need the BKL on their face may still depend on its acquisition to serialize opens against driver initialization. So make those functions acquire then release the BKL to be on the safe side. Signed-off-by: Jonathan Corbet --- drivers/char/cs5535_gpio.c | 4 ++-- drivers/char/dtlk.c | 5 +++-- drivers/char/ip2/ip2main.c | 34 ++-------------------------------- drivers/char/pc8736x_gpio.c | 3 ++- drivers/char/ppdev.c | 3 ++- drivers/char/scx200_gpio.c | 3 ++- drivers/char/tb0219.c | 3 ++- drivers/char/vr41xx_giu.c | 4 ++-- 8 files changed, 17 insertions(+), 42 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/cs5535_gpio.c b/drivers/char/cs5535_gpio.c index 628e3d3249d..04ba906b488 100644 --- a/drivers/char/cs5535_gpio.c +++ b/drivers/char/cs5535_gpio.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -153,12 +154,11 @@ static ssize_t cs5535_gpio_read(struct file *file, char __user *buf, return count; } -/* No BKL needed here - "mask" is the only global resource used - here and it's a boot-time parameter */ static int cs5535_gpio_open(struct inode *inode, struct file *file) { u32 m = iminor(inode); + cycle_kernel_lock(); /* the mask says which pins are usable by this driver */ if ((mask & (1 << m)) == 0) return -EINVAL; diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c index 433388c6023..6b900b297cc 100644 --- a/drivers/char/dtlk.c +++ b/drivers/char/dtlk.c @@ -56,6 +56,7 @@ #include /* for -EBUSY */ #include /* for request_region */ #include /* for loops_per_jiffy */ +#include /* cycle_kernel_lock() */ #include /* for inb_p, outb_p, inb, outb, etc. */ #include /* for get_user, etc. */ #include /* for wait_queue */ @@ -288,12 +289,12 @@ static int dtlk_ioctl(struct inode *inode, } } -/* No BKL needed here; "dtlk_busy" is the only global resource, - and it is not ever set by anybody (test is broken) */ +/* Note that nobody ever sets dtlk_busy... */ static int dtlk_open(struct inode *inode, struct file *file) { TRACE_TEXT("(dtlk_open"); + cycle_kernel_lock(); nonseekable_open(inode, file); switch (iminor(inode)) { case DTLK_MINOR: diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c index 70957acaa96..a978c57b6b2 100644 --- a/drivers/char/ip2/ip2main.c +++ b/drivers/char/ip2/ip2main.c @@ -98,6 +98,7 @@ #include #include #include +#include #include #include @@ -2931,42 +2932,11 @@ ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg ) static int ip2_ipl_open( struct inode *pInode, struct file *pFile ) { - unsigned int iplminor = iminor(pInode); - i2eBordStrPtr pB; - i2ChanStrPtr pCh; #ifdef IP2DEBUG_IPL printk (KERN_DEBUG "IP2IPL: open\n" ); #endif - - switch(iplminor) { - // These are the IPL devices - case 0: - case 4: - case 8: - case 12: - break; - - // These are the status devices - case 1: - case 5: - case 9: - case 13: - break; - - // These are the debug devices - case 2: - case 6: - case 10: - case 14: - pB = i2BoardPtrTable[iplminor / 4]; - pCh = (i2ChanStrPtr) pB->i2eChannelPtr; - break; - - // This is the trace device - case 3: - break; - } + cycle_kernel_lock(); return 0; } diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c index 8715dc9f4a5..b930de50407 100644 --- a/drivers/char/pc8736x_gpio.c +++ b/drivers/char/pc8736x_gpio.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #define DEVNAME "pc8736x_gpio" @@ -212,12 +213,12 @@ static struct nsc_gpio_ops pc8736x_gpio_ops = { .gpio_current = pc8736x_gpio_current }; -/* No BKL needed here; no global resources accessed */ static int pc8736x_gpio_open(struct inode *inode, struct file *file) { unsigned m = iminor(inode); file->private_data = &pc8736x_gpio_ops; + cycle_kernel_lock(); dev_dbg(&pdev->dev, "open %d\n", m); if (m >= PC8736X_GPIO_CT) diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c index ce198757488..f6e6acadd9a 100644 --- a/drivers/char/ppdev.c +++ b/drivers/char/ppdev.c @@ -66,6 +66,7 @@ #include #include #include +#include #include #define PP_VERSION "ppdev: user-space parallel port driver" @@ -633,12 +634,12 @@ static int pp_ioctl(struct inode *inode, struct file *file, return 0; } -/* No BKL needed here: only local resources used */ static int pp_open (struct inode * inode, struct file * file) { unsigned int minor = iminor(inode); struct pp_struct *pp; + cycle_kernel_lock(); if (minor >= PARPORT_MAX) return -ENXIO; diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c index be2c623a986..1d9100561c8 100644 --- a/drivers/char/scx200_gpio.c +++ b/drivers/char/scx200_gpio.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -46,12 +47,12 @@ struct nsc_gpio_ops scx200_gpio_ops = { }; EXPORT_SYMBOL_GPL(scx200_gpio_ops); -/* No BKL needed here: no global resources used */ static int scx200_gpio_open(struct inode *inode, struct file *file) { unsigned m = iminor(inode); file->private_data = &scx200_gpio_ops; + cycle_kernel_lock(); if (m >= MAX_PINS) return -EINVAL; return nonseekable_open(inode, file); diff --git a/drivers/char/tb0219.c b/drivers/char/tb0219.c index db8c2ca2ce4..6062b62800f 100644 --- a/drivers/char/tb0219.c +++ b/drivers/char/tb0219.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -232,11 +233,11 @@ static ssize_t tanbac_tb0219_write(struct file *file, const char __user *data, return i; } -/* No BKL needed here; no global resources accessed */ static int tanbac_tb0219_open(struct inode *inode, struct file *file) { unsigned int minor; + cycle_kernel_lock(); minor = iminor(inode); switch (minor) { case 0: diff --git a/drivers/char/vr41xx_giu.c b/drivers/char/vr41xx_giu.c index 412937fdb95..ffe9b4e3072 100644 --- a/drivers/char/vr41xx_giu.c +++ b/drivers/char/vr41xx_giu.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -543,12 +544,11 @@ static ssize_t gpio_write(struct file *file, const char __user *data, return i; } -/* No BKL needed here; only global (giu_nr_pins) is only set - at probe time */ static int gpio_open(struct inode *inode, struct file *file) { unsigned int pin; + cycle_kernel_lock(); pin = iminor(inode); if (pin >= giu_nr_pins) return -EBADF; -- cgit v1.2.3 From 5ca6a93d802a9d110127556e5d3ed032fd273e03 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Mon, 19 May 2008 16:06:52 +1000 Subject: bkl-removal viotape fixup Signed-off-by: Stephen Rothwell Signed-off-by: Jonathan Corbet --- drivers/char/viotape.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/char') diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c index af03d270930..a171d894b7e 100644 --- a/drivers/char/viotape.c +++ b/drivers/char/viotape.c @@ -688,7 +688,7 @@ static int viotap_open(struct inode *inode, struct file *file) if (op == NULL) return -ENOMEM; - lock_kernel() + lock_kernel(); get_dev_info(file->f_path.dentry->d_inode, &devi); /* Note: We currently only support one mode! */ -- cgit v1.2.3 From a076230134f3083a58cef99e48b127818ef01e7a Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:15:30 +0200 Subject: agp-frontend: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/char/agp/frontend.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c index 857b26227d8..963eff28fa0 100644 --- a/drivers/char/agp/frontend.c +++ b/drivers/char/agp/frontend.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include "agp.h" @@ -677,6 +678,7 @@ static int agp_open(struct inode *inode, struct file *file) struct agp_client *client; int rc = -ENXIO; + lock_kernel(); mutex_lock(&(agp_fe.agp_mutex)); if (minor != AGPGART_MINOR) @@ -703,12 +705,14 @@ static int agp_open(struct inode *inode, struct file *file) agp_insert_file_private(priv); DBG("private=%p, client=%p", priv, client); mutex_unlock(&(agp_fe.agp_mutex)); + unlock_kernel(); return 0; err_out_nomem: rc = -ENOMEM; err_out: mutex_unlock(&(agp_fe.agp_mutex)); + unlock_kernel(); return rc; } -- cgit v1.2.3 From 2861ead38b8a376888c3f63b9c8e45d4cee02117 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:15:33 +0200 Subject: apm-emulation: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/char/apm-emulation.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c index cdd876dbb2b..da8a1658a27 100644 --- a/drivers/char/apm-emulation.c +++ b/drivers/char/apm-emulation.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -416,6 +417,7 @@ static int apm_open(struct inode * inode, struct file * filp) { struct apm_user *as; + lock_kernel(); as = kzalloc(sizeof(*as), GFP_KERNEL); if (as) { /* @@ -435,6 +437,7 @@ static int apm_open(struct inode * inode, struct file * filp) filp->private_data = as; } + unlock_kernel(); return as ? 0 : -ENOMEM; } -- cgit v1.2.3 From 556889a4ae89d5f2adf98cac58ecf9326b0d0297 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:15:41 +0200 Subject: briq_panel: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/char/briq_panel.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/briq_panel.c b/drivers/char/briq_panel.c index b6f2639f903..d8cff909001 100644 --- a/drivers/char/briq_panel.c +++ b/drivers/char/briq_panel.c @@ -6,6 +6,7 @@ #include +#include #include #include #include @@ -67,11 +68,15 @@ static void set_led(char state) static int briq_panel_open(struct inode *ino, struct file *filep) { - /* enforce single access */ - if (vfd_is_open) + lock_kernel(); + /* enforce single access, vfd_is_open is protected by BKL */ + if (vfd_is_open) { + unlock_kernel(); return -EBUSY; + } vfd_is_open = 1; + unlock_kernel(); return 0; } -- cgit v1.2.3 From 7ccef46320ecd52c4d20c8aad592599df76bb7a1 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:15:49 +0200 Subject: ds1286: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/char/ds1286.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/ds1286.c b/drivers/char/ds1286.c index ea35ab2c990..fb584938c9c 100644 --- a/drivers/char/ds1286.c +++ b/drivers/char/ds1286.c @@ -27,6 +27,7 @@ * option) any later version. */ #include +#include #include #include #include @@ -252,6 +253,7 @@ static int ds1286_ioctl(struct inode *inode, struct file *file, static int ds1286_open(struct inode *inode, struct file *file) { + lock_kernel(); spin_lock_irq(&ds1286_lock); if (ds1286_status & RTC_IS_OPEN) @@ -260,10 +262,12 @@ static int ds1286_open(struct inode *inode, struct file *file) ds1286_status |= RTC_IS_OPEN; spin_unlock_irq(&ds1286_lock); + unlock_kernel(); return 0; out_busy: spin_lock_irq(&ds1286_lock); + unlock_kernel(); return -EBUSY; } -- cgit v1.2.3 From 080c2226474fa3060fadce9a2341004f477aadb3 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:15:50 +0200 Subject: ds1620: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/char/ds1620.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'drivers/char') diff --git a/drivers/char/ds1620.c b/drivers/char/ds1620.c index 334ad5bbe6b..34275c6f1da 100644 --- a/drivers/char/ds1620.c +++ b/drivers/char/ds1620.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -208,6 +209,12 @@ static void ds1620_read_state(struct therm *therm) therm->hi = cvt_9_to_int(ds1620_in(THERM_READ_TH, 9)); } +static int ds1620_open(struct inode *inode, struct file *file) +{ + cycle_kernel_lock(); + return nonseekable_open(inode, file); +} + static ssize_t ds1620_read(struct file *file, char __user *buf, size_t count, loff_t *ptr) { @@ -336,7 +343,7 @@ static struct proc_dir_entry *proc_therm_ds1620; static const struct file_operations ds1620_fops = { .owner = THIS_MODULE, - .open = nonseekable_open, + .open = ds1620_open, .read = ds1620_read, .ioctl = ds1620_ioctl, }; -- cgit v1.2.3 From 89c7de08c5fc059c4f6231571416d9bc0bbc91d4 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:15:52 +0200 Subject: efirtc: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/char/efirtc.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/efirtc.c b/drivers/char/efirtc.c index 49233f58987..d57ca3e4e53 100644 --- a/drivers/char/efirtc.c +++ b/drivers/char/efirtc.c @@ -28,6 +28,7 @@ */ +#include #include #include #include @@ -272,6 +273,7 @@ efi_rtc_open(struct inode *inode, struct file *file) * We do accept multiple open files at the same time as we * synchronize on the per call operation. */ + cycle_kernel_lock(); return 0; } -- cgit v1.2.3 From 742a2fe31bf311d065a2bbacc2b363103b351300 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:15:55 +0200 Subject: genrtc: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/char/genrtc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers/char') diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c index 69f0a2993af..aac0985a572 100644 --- a/drivers/char/genrtc.c +++ b/drivers/char/genrtc.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -338,12 +339,16 @@ static int gen_rtc_ioctl(struct inode *inode, struct file *file, static int gen_rtc_open(struct inode *inode, struct file *file) { - if (gen_rtc_status & RTC_IS_OPEN) + lock_kernel(); + if (gen_rtc_status & RTC_IS_OPEN) { + unlock_kernel(); return -EBUSY; + } gen_rtc_status |= RTC_IS_OPEN; gen_rtc_irq_data = 0; irq_active = 0; + unlock_kernel(); return 0; } -- cgit v1.2.3 From 48b81880519274d2a8b3e9919a47d91d05a1c964 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:15:59 +0200 Subject: hpet: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/char/hpet.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index e7fb0bca366..fb0a85a1eb3 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -193,6 +194,7 @@ static int hpet_open(struct inode *inode, struct file *file) if (file->f_mode & FMODE_WRITE) return -EINVAL; + lock_kernel(); spin_lock_irq(&hpet_lock); for (devp = NULL, hpetp = hpets; hpetp && !devp; hpetp = hpetp->hp_next) @@ -207,6 +209,7 @@ static int hpet_open(struct inode *inode, struct file *file) if (!devp) { spin_unlock_irq(&hpet_lock); + unlock_kernel(); return -EBUSY; } @@ -214,6 +217,7 @@ static int hpet_open(struct inode *inode, struct file *file) devp->hd_irqdata = 0; devp->hd_flags |= HPET_OPEN; spin_unlock_irq(&hpet_lock); + unlock_kernel(); return 0; } -- cgit v1.2.3 From a9c4e8f74ba26f10cf78fed7c5b863ea50988856 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:16:00 +0200 Subject: hw-random: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/char/hw_random/core.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c index 662d60e44e9..e5d583c84e4 100644 --- a/drivers/char/hw_random/core.c +++ b/drivers/char/hw_random/core.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -86,6 +87,7 @@ static int rng_dev_open(struct inode *inode, struct file *filp) return -EINVAL; if (filp->f_mode & FMODE_WRITE) return -EINVAL; + cycle_kernel_lock(); return 0; } -- cgit v1.2.3 From b0e54f7c477ad24fa0d49baed942c5a5909c748b Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:16:03 +0200 Subject: ip27-rtc: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/char/ip27-rtc.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/ip27-rtc.c b/drivers/char/ip27-rtc.c index 86e6538a77b..ec9d0443d92 100644 --- a/drivers/char/ip27-rtc.c +++ b/drivers/char/ip27-rtc.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -163,15 +164,18 @@ static long rtc_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) static int rtc_open(struct inode *inode, struct file *file) { + lock_kernel(); spin_lock_irq(&rtc_lock); if (rtc_status & RTC_IS_OPEN) { spin_unlock_irq(&rtc_lock); + unlock_kernel(); return -EBUSY; } rtc_status |= RTC_IS_OPEN; spin_unlock_irq(&rtc_lock); + unlock_kernel(); return 0; } -- cgit v1.2.3 From af96f0103d332be92c42a44accf731da667ecc03 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:16:04 +0200 Subject: ipmi-watchdog: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/char/ipmi/ipmi_watchdog.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c index 1b9a8704781..357d99b9d0e 100644 --- a/drivers/char/ipmi/ipmi_watchdog.c +++ b/drivers/char/ipmi/ipmi_watchdog.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -819,6 +820,8 @@ static int ipmi_open(struct inode *ino, struct file *filep) if (test_and_set_bit(0, &ipmi_wdog_open)) return -EBUSY; + cycle_kernel_lock(); + /* * Don't start the timer now, let it start on the * first heartbeat. -- cgit v1.2.3 From 600bf8140c22e473ef0806ae45214aaaf53e0da3 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:16:10 +0200 Subject: lcd: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/char/lcd.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/lcd.c b/drivers/char/lcd.c index 4fe9206f84d..1c29b20e4f4 100644 --- a/drivers/char/lcd.c +++ b/drivers/char/lcd.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -414,6 +415,8 @@ static int lcd_ioctl(struct inode *inode, struct file *file, static int lcd_open(struct inode *inode, struct file *file) { + cycle_kernel_lock(); + if (!lcd_present) return -ENXIO; else -- cgit v1.2.3 From db41bc9c4dfeed656dfd63d26883f81abc4005df Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:16:23 +0200 Subject: mwave-mwavedd: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/char/mwave/mwavedd.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/mwave/mwavedd.c b/drivers/char/mwave/mwavedd.c index 8d14823b051..50243fcd87e 100644 --- a/drivers/char/mwave/mwavedd.c +++ b/drivers/char/mwave/mwavedd.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include "smapi.h" @@ -100,6 +101,7 @@ static int mwave_open(struct inode *inode, struct file *file) PRINTK_2(TRACE_MWAVE, "mwavedd::mwave_open, exit return retval %x\n", retval); + cycle_kernel_lock(); return retval; } -- cgit v1.2.3 From 930ab4e532623795f934467c452a8c71be2c30fe Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:16:26 +0200 Subject: nvram: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/char/nvram.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c index 98dec380af4..197cd7a0c33 100644 --- a/drivers/char/nvram.c +++ b/drivers/char/nvram.c @@ -107,6 +107,7 @@ #include #include #include +#include #include #include @@ -333,12 +334,14 @@ nvram_ioctl(struct inode *inode, struct file *file, static int nvram_open(struct inode *inode, struct file *file) { + lock_kernel(); spin_lock(&nvram_state_lock); if ((nvram_open_cnt && (file->f_flags & O_EXCL)) || (nvram_open_mode & NVRAM_EXCL) || ((file->f_mode & 2) && (nvram_open_mode & NVRAM_WRITE))) { spin_unlock(&nvram_state_lock); + unlock_kernel(); return -EBUSY; } @@ -349,6 +352,7 @@ nvram_open(struct inode *inode, struct file *file) nvram_open_cnt++; spin_unlock(&nvram_state_lock); + unlock_kernel(); return 0; } -- cgit v1.2.3 From 4333deee6b7a5a82afb9e700e76cb46e68fde68d Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:16:37 +0200 Subject: rtc: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/char/rtc.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c index 5f80a9dff57..10f06a6bfeb 100644 --- a/drivers/char/rtc.c +++ b/drivers/char/rtc.c @@ -73,6 +73,7 @@ #include #include #include +#include #include #include #include @@ -733,6 +734,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, * needed here. Or anywhere else in this driver. */ static int rtc_open(struct inode *inode, struct file *file) { + lock_kernel(); spin_lock_irq(&rtc_lock); if (rtc_status & RTC_IS_OPEN) @@ -742,10 +744,12 @@ static int rtc_open(struct inode *inode, struct file *file) rtc_irq_data = 0; spin_unlock_irq(&rtc_lock); + unlock_kernel(); return 0; out_busy: spin_unlock_irq(&rtc_lock); + unlock_kernel(); return -EBUSY; } -- cgit v1.2.3 From f8f2c79d594463427f7114cedb1555110d547d89 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:16:46 +0200 Subject: sonypi: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/char/sonypi.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c index 58533de5902..85e0eb76eea 100644 --- a/drivers/char/sonypi.c +++ b/drivers/char/sonypi.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include @@ -906,12 +907,14 @@ static int sonypi_misc_release(struct inode *inode, struct file *file) static int sonypi_misc_open(struct inode *inode, struct file *file) { + lock_kernel(); mutex_lock(&sonypi_device.lock); /* Flush input queue on first open */ if (!sonypi_device.open_count) kfifo_reset(sonypi_device.fifo); sonypi_device.open_count++; mutex_unlock(&sonypi_device.lock); + unlock_kernel(); return 0; } -- cgit v1.2.3 From 25368ca579905efe7f7dda43c252eb7b371de98c Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Tue, 20 May 2008 19:16:51 +0200 Subject: tpm-tpm: BKL pushdown Signed-off-by: Arnd Bergmann --- drivers/char/tpm/tpm.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c index a5d8bcb4000..e1fc193d939 100644 --- a/drivers/char/tpm/tpm.c +++ b/drivers/char/tpm/tpm.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "tpm.h" @@ -897,6 +898,7 @@ int tpm_open(struct inode *inode, struct file *file) int rc = 0, minor = iminor(inode); struct tpm_chip *chip = NULL, *pos; + lock_kernel(); spin_lock(&driver_lock); list_for_each_entry(pos, &tpm_chip_list, list) { @@ -926,16 +928,19 @@ int tpm_open(struct inode *inode, struct file *file) if (chip->data_buffer == NULL) { chip->num_opens--; put_device(chip->dev); + unlock_kernel(); return -ENOMEM; } atomic_set(&chip->data_pending, 0); file->private_data = chip; + unlock_kernel(); return 0; err_out: spin_unlock(&driver_lock); + unlock_kernel(); return rc; } EXPORT_SYMBOL_GPL(tpm_open); -- cgit v1.2.3 From 5d1e3230f4b4a93c6561b0fb5a99bb1eb02227ed Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Thu, 19 Jun 2008 16:04:53 -0600 Subject: tty_io: fasync BKL pushdown Signed-off-by: Jonathan Corbet --- drivers/char/tty_io.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index fd182f2e4a6..eda27899372 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c @@ -2909,15 +2909,16 @@ static int tty_fasync(int fd, struct file *filp, int on) { struct tty_struct *tty; unsigned long flags; - int retval; + int retval = 0; + lock_kernel(); tty = (struct tty_struct *)filp->private_data; if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "tty_fasync")) - return 0; + goto out; retval = fasync_helper(fd, filp, on, &tty->fasync); if (retval <= 0) - return retval; + goto out; if (on) { enum pid_type type; @@ -2935,12 +2936,15 @@ static int tty_fasync(int fd, struct file *filp, int on) spin_unlock_irqrestore(&tty->ctrl_lock, flags); retval = __f_setown(filp, pid, type, 0); if (retval) - return retval; + goto out; } else { if (!tty->fasync && !waitqueue_active(&tty->read_wait)) tty->minimum_to_wake = N_TTY_BUF_SIZE; } - return 0; + retval = 0; +out: + unlock_kernel(); + return retval; } /** -- cgit v1.2.3 From 70b028b7ea94f1b36c61f3ee1c921cc3a87812e6 Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Mon, 23 Jun 2008 17:00:14 -0600 Subject: ipmi: fasync BKL pushdown This driver really needs it to avoid races against open() Signed-off-by: Jonathan Corbet --- drivers/char/ipmi/ipmi_devintf.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c index c816656d6bf..c11a4048345 100644 --- a/drivers/char/ipmi/ipmi_devintf.c +++ b/drivers/char/ipmi/ipmi_devintf.c @@ -101,7 +101,9 @@ static int ipmi_fasync(int fd, struct file *file, int on) struct ipmi_file_private *priv = file->private_data; int result; + lock_kernel(); /* could race against open() otherwise */ result = fasync_helper(fd, file, on, &priv->fasync_queue); + unlock_kernel(); return (result); } -- cgit v1.2.3