aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/aoe/aoechr.c7
-rw-r--r--drivers/block/paride/pg.c22
-rw-r--r--drivers/block/paride/pt.c7
3 files changed, 28 insertions, 8 deletions
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c
index e8e60e7a2e7..d1de68a3192 100644
--- a/drivers/block/aoe/aoechr.c
+++ b/drivers/block/aoe/aoechr.c
@@ -7,6 +7,7 @@
7#include <linux/hdreg.h> 7#include <linux/hdreg.h>
8#include <linux/blkdev.h> 8#include <linux/blkdev.h>
9#include <linux/delay.h> 9#include <linux/delay.h>
10#include <linux/smp_lock.h>
10#include "aoe.h" 11#include "aoe.h"
11 12
12enum { 13enum {
@@ -174,12 +175,16 @@ aoechr_open(struct inode *inode, struct file *filp)
174{ 175{
175 int n, i; 176 int n, i;
176 177
178 lock_kernel();
177 n = iminor(inode); 179 n = iminor(inode);
178 filp->private_data = (void *) (unsigned long) n; 180 filp->private_data = (void *) (unsigned long) n;
179 181
180 for (i = 0; i < ARRAY_SIZE(chardevs); ++i) 182 for (i = 0; i < ARRAY_SIZE(chardevs); ++i)
181 if (chardevs[i].minor == n) 183 if (chardevs[i].minor == n) {
184 unlock_kernel();
182 return 0; 185 return 0;
186 }
187 unlock_kernel();
183 return -EINVAL; 188 return -EINVAL;
184} 189}
185 190
diff --git a/drivers/block/paride/pg.c b/drivers/block/paride/pg.c
index ab86e23ddc6..9d92636350e 100644
--- a/drivers/block/paride/pg.c
+++ b/drivers/block/paride/pg.c
@@ -162,6 +162,7 @@ enum {D_PRT, D_PRO, D_UNI, D_MOD, D_SLV, D_DLY};
162#include <linux/pg.h> 162#include <linux/pg.h>
163#include <linux/device.h> 163#include <linux/device.h>
164#include <linux/sched.h> /* current, TASK_* */ 164#include <linux/sched.h> /* current, TASK_* */
165#include <linux/smp_lock.h>
165#include <linux/jiffies.h> 166#include <linux/jiffies.h>
166 167
167#include <asm/uaccess.h> 168#include <asm/uaccess.h>
@@ -515,12 +516,18 @@ static int pg_open(struct inode *inode, struct file *file)
515{ 516{
516 int unit = iminor(inode) & 0x7f; 517 int unit = iminor(inode) & 0x7f;
517 struct pg *dev = &devices[unit]; 518 struct pg *dev = &devices[unit];
519 int ret = 0;
518 520
519 if ((unit >= PG_UNITS) || (!dev->present)) 521 lock_kernel();
520 return -ENODEV; 522 if ((unit >= PG_UNITS) || (!dev->present)) {
523 ret = -ENODEV;
524 goto out;
525 }
521 526
522 if (test_and_set_bit(0, &dev->access)) 527 if (test_and_set_bit(0, &dev->access)) {
523 return -EBUSY; 528 ret = -EBUSY;
529 goto out;
530 }
524 531
525 if (dev->busy) { 532 if (dev->busy) {
526 pg_reset(dev); 533 pg_reset(dev);
@@ -533,12 +540,15 @@ static int pg_open(struct inode *inode, struct file *file)
533 if (dev->bufptr == NULL) { 540 if (dev->bufptr == NULL) {
534 clear_bit(0, &dev->access); 541 clear_bit(0, &dev->access);
535 printk("%s: buffer allocation failed\n", dev->name); 542 printk("%s: buffer allocation failed\n", dev->name);
536 return -ENOMEM; 543 ret = -ENOMEM;
544 goto out;
537 } 545 }
538 546
539 file->private_data = dev; 547 file->private_data = dev;
540 548
541 return 0; 549out:
550 unlock_kernel();
551 return ret;
542} 552}
543 553
544static int pg_release(struct inode *inode, struct file *file) 554static int pg_release(struct inode *inode, struct file *file)
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c
index 27455ee1e9d..5c74c3574a5 100644
--- a/drivers/block/paride/pt.c
+++ b/drivers/block/paride/pt.c
@@ -650,8 +650,11 @@ static int pt_open(struct inode *inode, struct file *file)
650 struct pt_unit *tape = pt + unit; 650 struct pt_unit *tape = pt + unit;
651 int err; 651 int err;
652 652
653 if (unit >= PT_UNITS || (!tape->present)) 653 lock_kernel();
654 if (unit >= PT_UNITS || (!tape->present)) {
655 unlock_kernel();
654 return -ENODEV; 656 return -ENODEV;
657 }
655 658
656 err = -EBUSY; 659 err = -EBUSY;
657 if (!atomic_dec_and_test(&tape->available)) 660 if (!atomic_dec_and_test(&tape->available))
@@ -678,10 +681,12 @@ static int pt_open(struct inode *inode, struct file *file)
678 } 681 }
679 682
680 file->private_data = tape; 683 file->private_data = tape;
684 unlock_kernel();
681 return 0; 685 return 0;
682 686
683out: 687out:
684 atomic_inc(&tape->available); 688 atomic_inc(&tape->available);
689 unlock_kernel();
685 return err; 690 return err;
686} 691}
687 692