diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-14 17:48:31 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-14 17:48:31 -0400 |
commit | d1794f2c5b5817eb79ccc5e00701ca748d1b073a (patch) | |
tree | 5a4c98e694e88a8c82f342d0cc9edb2a4cbbef36 | |
parent | a41eebab7537890409ea9dfe0fcda9b5fbdb090d (diff) | |
parent | 2fceef397f9880b212a74c418290ce69e7ac00eb (diff) |
Merge branch 'bkl-removal' of git://git.lwn.net/linux-2.6
* 'bkl-removal' of git://git.lwn.net/linux-2.6: (146 commits)
IB/umad: BKL is not needed for ib_umad_open()
IB/uverbs: BKL is not needed for ib_uverbs_open()
bf561-coreb: BKL unneeded for open()
Call fasync() functions without the BKL
snd/PCM: fasync BKL pushdown
ipmi: fasync BKL pushdown
ecryptfs: fasync BKL pushdown
Bluetooth VHCI: fasync BKL pushdown
tty_io: fasync BKL pushdown
tun: fasync BKL pushdown
i2o: fasync BKL pushdown
mpt: fasync BKL pushdown
Remove BKL from remote_llseek v2
Make FAT users happier by not deadlocking
x86-mce: BKL pushdown
vmwatchdog: BKL pushdown
vmcp: BKL pushdown
via-pmu: BKL pushdown
uml-random: BKL pushdown
uml-mmapper: BKL pushdown
...
179 files changed, 1092 insertions, 350 deletions
diff --git a/arch/blackfin/mach-bf561/coreb.c b/arch/blackfin/mach-bf561/coreb.c index 1b44e9e6dc3b..8598098c0840 100644 --- a/arch/blackfin/mach-bf561/coreb.c +++ b/arch/blackfin/mach-bf561/coreb.c | |||
@@ -194,6 +194,7 @@ static loff_t coreb_lseek(struct file *file, loff_t offset, int origin) | |||
194 | return ret; | 194 | return ret; |
195 | } | 195 | } |
196 | 196 | ||
197 | /* No BKL needed here */ | ||
197 | static int coreb_open(struct inode *inode, struct file *file) | 198 | static int coreb_open(struct inode *inode, struct file *file) |
198 | { | 199 | { |
199 | spin_lock_irq(&coreb_lock); | 200 | spin_lock_irq(&coreb_lock); |
diff --git a/arch/cris/arch-v10/drivers/eeprom.c b/arch/cris/arch-v10/drivers/eeprom.c index f1cac9dc75b8..1f2ae909d3e6 100644 --- a/arch/cris/arch-v10/drivers/eeprom.c +++ b/arch/cris/arch-v10/drivers/eeprom.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/delay.h> | 29 | #include <linux/delay.h> |
30 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
31 | #include <linux/smp_lock.h> | ||
31 | #include <linux/wait.h> | 32 | #include <linux/wait.h> |
32 | #include <asm/uaccess.h> | 33 | #include <asm/uaccess.h> |
33 | #include "i2c.h" | 34 | #include "i2c.h" |
@@ -375,10 +376,9 @@ int __init eeprom_init(void) | |||
375 | } | 376 | } |
376 | 377 | ||
377 | /* Opens the device. */ | 378 | /* Opens the device. */ |
378 | |||
379 | static int eeprom_open(struct inode * inode, struct file * file) | 379 | static int eeprom_open(struct inode * inode, struct file * file) |
380 | { | 380 | { |
381 | 381 | cycle_kernel_lock(); | |
382 | if(iminor(inode) != EEPROM_MINOR_NR) | 382 | if(iminor(inode) != EEPROM_MINOR_NR) |
383 | return -ENXIO; | 383 | return -ENXIO; |
384 | if(imajor(inode) != EEPROM_MAJOR_NR) | 384 | if(imajor(inode) != EEPROM_MAJOR_NR) |
diff --git a/arch/cris/arch-v10/drivers/gpio.c b/arch/cris/arch-v10/drivers/gpio.c index 68a998bd1069..86048e697eb5 100644 --- a/arch/cris/arch-v10/drivers/gpio.c +++ b/arch/cris/arch-v10/drivers/gpio.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/errno.h> | 16 | #include <linux/errno.h> |
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/fs.h> | 18 | #include <linux/fs.h> |
19 | #include <linux/smp_lock.h> | ||
19 | #include <linux/string.h> | 20 | #include <linux/string.h> |
20 | #include <linux/poll.h> | 21 | #include <linux/poll.h> |
21 | #include <linux/init.h> | 22 | #include <linux/init.h> |
@@ -323,6 +324,7 @@ gpio_open(struct inode *inode, struct file *filp) | |||
323 | if (!priv) | 324 | if (!priv) |
324 | return -ENOMEM; | 325 | return -ENOMEM; |
325 | 326 | ||
327 | lock_kernel(); | ||
326 | priv->minor = p; | 328 | priv->minor = p; |
327 | 329 | ||
328 | /* initialize the io/alarm struct */ | 330 | /* initialize the io/alarm struct */ |
@@ -357,6 +359,7 @@ gpio_open(struct inode *inode, struct file *filp) | |||
357 | alarmlist = priv; | 359 | alarmlist = priv; |
358 | spin_unlock_irqrestore(&gpio_lock, flags); | 360 | spin_unlock_irqrestore(&gpio_lock, flags); |
359 | 361 | ||
362 | unlock_kernel(); | ||
360 | return 0; | 363 | return 0; |
361 | } | 364 | } |
362 | 365 | ||
diff --git a/arch/cris/arch-v10/drivers/i2c.c b/arch/cris/arch-v10/drivers/i2c.c index d6d22067d0c8..2797e67ce4f4 100644 --- a/arch/cris/arch-v10/drivers/i2c.c +++ b/arch/cris/arch-v10/drivers/i2c.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
18 | #include <linux/smp_lock.h> | ||
18 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
19 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
20 | #include <linux/fs.h> | 21 | #include <linux/fs.h> |
@@ -566,6 +567,7 @@ i2c_readreg(unsigned char theSlave, unsigned char theReg) | |||
566 | static int | 567 | static int |
567 | i2c_open(struct inode *inode, struct file *filp) | 568 | i2c_open(struct inode *inode, struct file *filp) |
568 | { | 569 | { |
570 | cycle_kernel_lock(); | ||
569 | return 0; | 571 | return 0; |
570 | } | 572 | } |
571 | 573 | ||
diff --git a/arch/cris/arch-v10/drivers/sync_serial.c b/arch/cris/arch-v10/drivers/sync_serial.c index 069546e342c5..91fea623c7c9 100644 --- a/arch/cris/arch-v10/drivers/sync_serial.c +++ b/arch/cris/arch-v10/drivers/sync_serial.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
22 | #include <linux/poll.h> | 22 | #include <linux/poll.h> |
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/smp_lock.h> | ||
24 | #include <linux/timer.h> | 25 | #include <linux/timer.h> |
25 | #include <asm/irq.h> | 26 | #include <asm/irq.h> |
26 | #include <asm/dma.h> | 27 | #include <asm/dma.h> |
@@ -443,18 +444,21 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
443 | int dev = MINOR(inode->i_rdev); | 444 | int dev = MINOR(inode->i_rdev); |
444 | struct sync_port *port; | 445 | struct sync_port *port; |
445 | int mode; | 446 | int mode; |
447 | int err = -EBUSY; | ||
446 | 448 | ||
449 | lock_kernel(); | ||
447 | DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev)); | 450 | DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev)); |
448 | 451 | ||
449 | if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled) { | 452 | if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled) { |
450 | DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev)); | 453 | DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev)); |
451 | return -ENODEV; | 454 | err = -ENODEV; |
455 | goto out; | ||
452 | } | 456 | } |
453 | port = &ports[dev]; | 457 | port = &ports[dev]; |
454 | /* Allow open this device twice (assuming one reader and one writer) */ | 458 | /* Allow open this device twice (assuming one reader and one writer) */ |
455 | if (port->busy == 2) { | 459 | if (port->busy == 2) { |
456 | DEBUG(printk(KERN_DEBUG "Device is busy.. \n")); | 460 | DEBUG(printk(KERN_DEBUG "Device is busy.. \n")); |
457 | return -EBUSY; | 461 | goto out; |
458 | } | 462 | } |
459 | if (port->init_irqs) { | 463 | if (port->init_irqs) { |
460 | if (port->use_dma) { | 464 | if (port->use_dma) { |
@@ -465,14 +469,14 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
465 | &ports[0])) { | 469 | &ports[0])) { |
466 | printk(KERN_CRIT "Can't alloc " | 470 | printk(KERN_CRIT "Can't alloc " |
467 | "sync serial port 1 IRQ"); | 471 | "sync serial port 1 IRQ"); |
468 | return -EBUSY; | 472 | goto out; |
469 | } else if (request_irq(25, rx_interrupt, 0, | 473 | } else if (request_irq(25, rx_interrupt, 0, |
470 | "synchronous serial 1 dma rx", | 474 | "synchronous serial 1 dma rx", |
471 | &ports[0])) { | 475 | &ports[0])) { |
472 | free_irq(24, &port[0]); | 476 | free_irq(24, &port[0]); |
473 | printk(KERN_CRIT "Can't alloc " | 477 | printk(KERN_CRIT "Can't alloc " |
474 | "sync serial port 1 IRQ"); | 478 | "sync serial port 1 IRQ"); |
475 | return -EBUSY; | 479 | goto out; |
476 | } else if (cris_request_dma(8, | 480 | } else if (cris_request_dma(8, |
477 | "synchronous serial 1 dma tr", | 481 | "synchronous serial 1 dma tr", |
478 | DMA_VERBOSE_ON_ERROR, | 482 | DMA_VERBOSE_ON_ERROR, |
@@ -482,7 +486,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
482 | printk(KERN_CRIT "Can't alloc " | 486 | printk(KERN_CRIT "Can't alloc " |
483 | "sync serial port 1 " | 487 | "sync serial port 1 " |
484 | "TX DMA channel"); | 488 | "TX DMA channel"); |
485 | return -EBUSY; | 489 | goto out; |
486 | } else if (cris_request_dma(9, | 490 | } else if (cris_request_dma(9, |
487 | "synchronous serial 1 dma rec", | 491 | "synchronous serial 1 dma rec", |
488 | DMA_VERBOSE_ON_ERROR, | 492 | DMA_VERBOSE_ON_ERROR, |
@@ -493,7 +497,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
493 | printk(KERN_CRIT "Can't alloc " | 497 | printk(KERN_CRIT "Can't alloc " |
494 | "sync serial port 1 " | 498 | "sync serial port 1 " |
495 | "RX DMA channel"); | 499 | "RX DMA channel"); |
496 | return -EBUSY; | 500 | goto out; |
497 | } | 501 | } |
498 | #endif | 502 | #endif |
499 | RESET_DMA(8); WAIT_DMA(8); | 503 | RESET_DMA(8); WAIT_DMA(8); |
@@ -520,14 +524,14 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
520 | &ports[1])) { | 524 | &ports[1])) { |
521 | printk(KERN_CRIT "Can't alloc " | 525 | printk(KERN_CRIT "Can't alloc " |
522 | "sync serial port 3 IRQ"); | 526 | "sync serial port 3 IRQ"); |
523 | return -EBUSY; | 527 | goto out; |
524 | } else if (request_irq(21, rx_interrupt, 0, | 528 | } else if (request_irq(21, rx_interrupt, 0, |
525 | "synchronous serial 3 dma rx", | 529 | "synchronous serial 3 dma rx", |
526 | &ports[1])) { | 530 | &ports[1])) { |
527 | free_irq(20, &ports[1]); | 531 | free_irq(20, &ports[1]); |
528 | printk(KERN_CRIT "Can't alloc " | 532 | printk(KERN_CRIT "Can't alloc " |
529 | "sync serial port 3 IRQ"); | 533 | "sync serial port 3 IRQ"); |
530 | return -EBUSY; | 534 | goto out; |
531 | } else if (cris_request_dma(4, | 535 | } else if (cris_request_dma(4, |
532 | "synchronous serial 3 dma tr", | 536 | "synchronous serial 3 dma tr", |
533 | DMA_VERBOSE_ON_ERROR, | 537 | DMA_VERBOSE_ON_ERROR, |
@@ -537,7 +541,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
537 | printk(KERN_CRIT "Can't alloc " | 541 | printk(KERN_CRIT "Can't alloc " |
538 | "sync serial port 3 " | 542 | "sync serial port 3 " |
539 | "TX DMA channel"); | 543 | "TX DMA channel"); |
540 | return -EBUSY; | 544 | goto out; |
541 | } else if (cris_request_dma(5, | 545 | } else if (cris_request_dma(5, |
542 | "synchronous serial 3 dma rec", | 546 | "synchronous serial 3 dma rec", |
543 | DMA_VERBOSE_ON_ERROR, | 547 | DMA_VERBOSE_ON_ERROR, |
@@ -548,7 +552,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
548 | printk(KERN_CRIT "Can't alloc " | 552 | printk(KERN_CRIT "Can't alloc " |
549 | "sync serial port 3 " | 553 | "sync serial port 3 " |
550 | "RX DMA channel"); | 554 | "RX DMA channel"); |
551 | return -EBUSY; | 555 | goto out; |
552 | } | 556 | } |
553 | #endif | 557 | #endif |
554 | RESET_DMA(4); WAIT_DMA(4); | 558 | RESET_DMA(4); WAIT_DMA(4); |
@@ -581,7 +585,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
581 | &ports[0])) { | 585 | &ports[0])) { |
582 | printk(KERN_CRIT "Can't alloc " | 586 | printk(KERN_CRIT "Can't alloc " |
583 | "sync serial manual irq"); | 587 | "sync serial manual irq"); |
584 | return -EBUSY; | 588 | goto out; |
585 | } | 589 | } |
586 | } else if (port == &ports[1]) { | 590 | } else if (port == &ports[1]) { |
587 | if (request_irq(8, | 591 | if (request_irq(8, |
@@ -591,7 +595,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
591 | &ports[1])) { | 595 | &ports[1])) { |
592 | printk(KERN_CRIT "Can't alloc " | 596 | printk(KERN_CRIT "Can't alloc " |
593 | "sync serial manual irq"); | 597 | "sync serial manual irq"); |
594 | return -EBUSY; | 598 | goto out; |
595 | } | 599 | } |
596 | } | 600 | } |
597 | port->init_irqs = 0; | 601 | port->init_irqs = 0; |
@@ -620,7 +624,11 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
620 | *R_IRQ_MASK1_SET = 1 << port->data_avail_bit; | 624 | *R_IRQ_MASK1_SET = 1 << port->data_avail_bit; |
621 | DEBUG(printk(KERN_DEBUG "sser%d rec started\n", dev)); | 625 | DEBUG(printk(KERN_DEBUG "sser%d rec started\n", dev)); |
622 | } | 626 | } |
623 | return 0; | 627 | ret = 0; |
628 | |||
629 | out: | ||
630 | unlock_kernel(); | ||
631 | return ret; | ||
624 | } | 632 | } |
625 | 633 | ||
626 | static int sync_serial_release(struct inode *inode, struct file *file) | 634 | static int sync_serial_release(struct inode *inode, struct file *file) |
diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c index 9fb58202be99..67c61ea86813 100644 --- a/arch/cris/arch-v32/drivers/cryptocop.c +++ b/arch/cris/arch-v32/drivers/cryptocop.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/string.h> | 11 | #include <linux/string.h> |
12 | #include <linux/fs.h> | 12 | #include <linux/fs.h> |
13 | #include <linux/mm.h> | 13 | #include <linux/mm.h> |
14 | #include <linux/smp_lock.h> | ||
14 | #include <linux/spinlock.h> | 15 | #include <linux/spinlock.h> |
15 | #include <linux/stddef.h> | 16 | #include <linux/stddef.h> |
16 | 17 | ||
@@ -2302,11 +2303,11 @@ static int cryptocop_job_setup(struct cryptocop_prio_job **pj, struct cryptocop_ | |||
2302 | return 0; | 2303 | return 0; |
2303 | } | 2304 | } |
2304 | 2305 | ||
2305 | |||
2306 | static int cryptocop_open(struct inode *inode, struct file *filp) | 2306 | static int cryptocop_open(struct inode *inode, struct file *filp) |
2307 | { | 2307 | { |
2308 | int p = iminor(inode); | 2308 | int p = iminor(inode); |
2309 | 2309 | ||
2310 | cycle_kernel_lock(); | ||
2310 | if (p != CRYPTOCOP_MINOR) return -EINVAL; | 2311 | if (p != CRYPTOCOP_MINOR) return -EINVAL; |
2311 | 2312 | ||
2312 | filp->private_data = NULL; | 2313 | filp->private_data = NULL; |
diff --git a/arch/cris/arch-v32/drivers/i2c.c b/arch/cris/arch-v32/drivers/i2c.c index c2fb7a5c1396..179e7b804331 100644 --- a/arch/cris/arch-v32/drivers/i2c.c +++ b/arch/cris/arch-v32/drivers/i2c.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/fs.h> | 33 | #include <linux/fs.h> |
34 | #include <linux/string.h> | 34 | #include <linux/string.h> |
35 | #include <linux/init.h> | 35 | #include <linux/init.h> |
36 | #include <linux/smp_lock.h> | ||
36 | 37 | ||
37 | #include <asm/etraxi2c.h> | 38 | #include <asm/etraxi2c.h> |
38 | 39 | ||
@@ -636,6 +637,7 @@ i2c_readreg(unsigned char theSlave, unsigned char theReg) | |||
636 | static int | 637 | static int |
637 | i2c_open(struct inode *inode, struct file *filp) | 638 | i2c_open(struct inode *inode, struct file *filp) |
638 | { | 639 | { |
640 | cycle_kernel_lock(); | ||
639 | return 0; | 641 | return 0; |
640 | } | 642 | } |
641 | 643 | ||
diff --git a/arch/cris/arch-v32/drivers/mach-a3/gpio.c b/arch/cris/arch-v32/drivers/mach-a3/gpio.c index de107dad9f4f..ef98608e5067 100644 --- a/arch/cris/arch-v32/drivers/mach-a3/gpio.c +++ b/arch/cris/arch-v32/drivers/mach-a3/gpio.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/interrupt.h> | 24 | #include <linux/interrupt.h> |
25 | #include <linux/spinlock.h> | 25 | #include <linux/spinlock.h> |
26 | #include <linux/smp_lock.h> | ||
26 | 27 | ||
27 | #include <asm/etraxgpio.h> | 28 | #include <asm/etraxgpio.h> |
28 | #include <hwregs/reg_map.h> | 29 | #include <hwregs/reg_map.h> |
@@ -390,6 +391,8 @@ static int gpio_open(struct inode *inode, struct file *filp) | |||
390 | 391 | ||
391 | if (!priv) | 392 | if (!priv) |
392 | return -ENOMEM; | 393 | return -ENOMEM; |
394 | |||
395 | lock_kernel(); | ||
393 | memset(priv, 0, sizeof(*priv)); | 396 | memset(priv, 0, sizeof(*priv)); |
394 | 397 | ||
395 | priv->minor = p; | 398 | priv->minor = p; |
@@ -412,6 +415,7 @@ static int gpio_open(struct inode *inode, struct file *filp) | |||
412 | spin_unlock_irq(&gpio_lock); | 415 | spin_unlock_irq(&gpio_lock); |
413 | } | 416 | } |
414 | 417 | ||
418 | unlock_kernel(); | ||
415 | return 0; | 419 | return 0; |
416 | } | 420 | } |
417 | 421 | ||
diff --git a/arch/cris/arch-v32/drivers/mach-fs/gpio.c b/arch/cris/arch-v32/drivers/mach-fs/gpio.c index 7863fd4efc2b..fe1fde893887 100644 --- a/arch/cris/arch-v32/drivers/mach-fs/gpio.c +++ b/arch/cris/arch-v32/drivers/mach-fs/gpio.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/interrupt.h> | 23 | #include <linux/interrupt.h> |
24 | #include <linux/spinlock.h> | 24 | #include <linux/spinlock.h> |
25 | #include <linux/smp_lock.h> | ||
25 | 26 | ||
26 | #include <asm/etraxgpio.h> | 27 | #include <asm/etraxgpio.h> |
27 | #include <hwregs/reg_map.h> | 28 | #include <hwregs/reg_map.h> |
@@ -426,9 +427,10 @@ gpio_open(struct inode *inode, struct file *filp) | |||
426 | return -EINVAL; | 427 | return -EINVAL; |
427 | 428 | ||
428 | priv = kmalloc(sizeof(struct gpio_private), GFP_KERNEL); | 429 | priv = kmalloc(sizeof(struct gpio_private), GFP_KERNEL); |
429 | |||
430 | if (!priv) | 430 | if (!priv) |
431 | return -ENOMEM; | 431 | return -ENOMEM; |
432 | |||
433 | lock_kernel(); | ||
432 | memset(priv, 0, sizeof(*priv)); | 434 | memset(priv, 0, sizeof(*priv)); |
433 | 435 | ||
434 | priv->minor = p; | 436 | priv->minor = p; |
@@ -449,6 +451,7 @@ gpio_open(struct inode *inode, struct file *filp) | |||
449 | alarmlist = priv; | 451 | alarmlist = priv; |
450 | spin_unlock_irq(&alarm_lock); | 452 | spin_unlock_irq(&alarm_lock); |
451 | 453 | ||
454 | unlock_kernel(); | ||
452 | return 0; | 455 | return 0; |
453 | } | 456 | } |
454 | 457 | ||
diff --git a/arch/cris/arch-v32/drivers/sync_serial.c b/arch/cris/arch-v32/drivers/sync_serial.c index 47c377df6fb3..d2a0fbf5341f 100644 --- a/arch/cris/arch-v32/drivers/sync_serial.c +++ b/arch/cris/arch-v32/drivers/sync_serial.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/major.h> | 14 | #include <linux/major.h> |
15 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/smp_lock.h> | ||
17 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
18 | #include <linux/poll.h> | 19 | #include <linux/poll.h> |
19 | #include <linux/init.h> | 20 | #include <linux/init.h> |
@@ -429,23 +430,26 @@ static inline int sync_data_avail_to_end(struct sync_port *port) | |||
429 | static int sync_serial_open(struct inode *inode, struct file *file) | 430 | static int sync_serial_open(struct inode *inode, struct file *file) |
430 | { | 431 | { |
431 | int dev = iminor(inode); | 432 | int dev = iminor(inode); |
433 | int ret = -EBUSY; | ||
432 | sync_port *port; | 434 | sync_port *port; |
433 | reg_dma_rw_cfg cfg = {.en = regk_dma_yes}; | 435 | reg_dma_rw_cfg cfg = {.en = regk_dma_yes}; |
434 | reg_dma_rw_intr_mask intr_mask = {.data = regk_dma_yes}; | 436 | reg_dma_rw_intr_mask intr_mask = {.data = regk_dma_yes}; |
435 | 437 | ||
438 | lock_kernel(); | ||
436 | DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev)); | 439 | DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev)); |
437 | 440 | ||
438 | if (dev < 0 || dev >= NBR_PORTS || !ports[dev].enabled) | 441 | if (dev < 0 || dev >= NBR_PORTS || !ports[dev].enabled) |
439 | { | 442 | { |
440 | DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev)); | 443 | DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev)); |
441 | return -ENODEV; | 444 | ret = -ENODEV; |
445 | goto out; | ||
442 | } | 446 | } |
443 | port = &ports[dev]; | 447 | port = &ports[dev]; |
444 | /* Allow open this device twice (assuming one reader and one writer) */ | 448 | /* Allow open this device twice (assuming one reader and one writer) */ |
445 | if (port->busy == 2) | 449 | if (port->busy == 2) |
446 | { | 450 | { |
447 | DEBUG(printk(KERN_DEBUG "Device is busy.. \n")); | 451 | DEBUG(printk(KERN_DEBUG "Device is busy.. \n")); |
448 | return -EBUSY; | 452 | goto out; |
449 | } | 453 | } |
450 | 454 | ||
451 | 455 | ||
@@ -459,7 +463,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
459 | "synchronous serial 0 dma tr", | 463 | "synchronous serial 0 dma tr", |
460 | &ports[0])) { | 464 | &ports[0])) { |
461 | printk(KERN_CRIT "Can't allocate sync serial port 0 IRQ"); | 465 | printk(KERN_CRIT "Can't allocate sync serial port 0 IRQ"); |
462 | return -EBUSY; | 466 | goto out; |
463 | } else if (request_irq(DMA_IN_INTR_VECT, | 467 | } else if (request_irq(DMA_IN_INTR_VECT, |
464 | rx_interrupt, | 468 | rx_interrupt, |
465 | 0, | 469 | 0, |
@@ -467,7 +471,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
467 | &ports[0])) { | 471 | &ports[0])) { |
468 | free_irq(DMA_OUT_INTR_VECT, &port[0]); | 472 | free_irq(DMA_OUT_INTR_VECT, &port[0]); |
469 | printk(KERN_CRIT "Can't allocate sync serial port 0 IRQ"); | 473 | printk(KERN_CRIT "Can't allocate sync serial port 0 IRQ"); |
470 | return -EBUSY; | 474 | goto out; |
471 | } else if (crisv32_request_dma(OUT_DMA_NBR, | 475 | } else if (crisv32_request_dma(OUT_DMA_NBR, |
472 | "synchronous serial 0 dma tr", | 476 | "synchronous serial 0 dma tr", |
473 | DMA_VERBOSE_ON_ERROR, | 477 | DMA_VERBOSE_ON_ERROR, |
@@ -476,7 +480,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
476 | free_irq(DMA_OUT_INTR_VECT, &port[0]); | 480 | free_irq(DMA_OUT_INTR_VECT, &port[0]); |
477 | free_irq(DMA_IN_INTR_VECT, &port[0]); | 481 | free_irq(DMA_IN_INTR_VECT, &port[0]); |
478 | printk(KERN_CRIT "Can't allocate sync serial port 0 TX DMA channel"); | 482 | printk(KERN_CRIT "Can't allocate sync serial port 0 TX DMA channel"); |
479 | return -EBUSY; | 483 | goto out; |
480 | } else if (crisv32_request_dma(IN_DMA_NBR, | 484 | } else if (crisv32_request_dma(IN_DMA_NBR, |
481 | "synchronous serial 0 dma rec", | 485 | "synchronous serial 0 dma rec", |
482 | DMA_VERBOSE_ON_ERROR, | 486 | DMA_VERBOSE_ON_ERROR, |
@@ -486,7 +490,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
486 | free_irq(DMA_OUT_INTR_VECT, &port[0]); | 490 | free_irq(DMA_OUT_INTR_VECT, &port[0]); |
487 | free_irq(DMA_IN_INTR_VECT, &port[0]); | 491 | free_irq(DMA_IN_INTR_VECT, &port[0]); |
488 | printk(KERN_CRIT "Can't allocate sync serial port 1 RX DMA channel"); | 492 | printk(KERN_CRIT "Can't allocate sync serial port 1 RX DMA channel"); |
489 | return -EBUSY; | 493 | goto out; |
490 | } | 494 | } |
491 | #endif | 495 | #endif |
492 | } | 496 | } |
@@ -499,7 +503,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
499 | "synchronous serial 1 dma tr", | 503 | "synchronous serial 1 dma tr", |
500 | &ports[1])) { | 504 | &ports[1])) { |
501 | printk(KERN_CRIT "Can't allocate sync serial port 1 IRQ"); | 505 | printk(KERN_CRIT "Can't allocate sync serial port 1 IRQ"); |
502 | return -EBUSY; | 506 | goto out; |
503 | } else if (request_irq(DMA7_INTR_VECT, | 507 | } else if (request_irq(DMA7_INTR_VECT, |
504 | rx_interrupt, | 508 | rx_interrupt, |
505 | 0, | 509 | 0, |
@@ -507,7 +511,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
507 | &ports[1])) { | 511 | &ports[1])) { |
508 | free_irq(DMA6_INTR_VECT, &ports[1]); | 512 | free_irq(DMA6_INTR_VECT, &ports[1]); |
509 | printk(KERN_CRIT "Can't allocate sync serial port 3 IRQ"); | 513 | printk(KERN_CRIT "Can't allocate sync serial port 3 IRQ"); |
510 | return -EBUSY; | 514 | goto out; |
511 | } else if (crisv32_request_dma( | 515 | } else if (crisv32_request_dma( |
512 | SYNC_SER1_TX_DMA_NBR, | 516 | SYNC_SER1_TX_DMA_NBR, |
513 | "synchronous serial 1 dma tr", | 517 | "synchronous serial 1 dma tr", |
@@ -517,7 +521,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
517 | free_irq(DMA6_INTR_VECT, &ports[1]); | 521 | free_irq(DMA6_INTR_VECT, &ports[1]); |
518 | free_irq(DMA7_INTR_VECT, &ports[1]); | 522 | free_irq(DMA7_INTR_VECT, &ports[1]); |
519 | printk(KERN_CRIT "Can't allocate sync serial port 3 TX DMA channel"); | 523 | printk(KERN_CRIT "Can't allocate sync serial port 3 TX DMA channel"); |
520 | return -EBUSY; | 524 | goto out; |
521 | } else if (crisv32_request_dma( | 525 | } else if (crisv32_request_dma( |
522 | SYNC_SER1_RX_DMA_NBR, | 526 | SYNC_SER1_RX_DMA_NBR, |
523 | "synchronous serial 3 dma rec", | 527 | "synchronous serial 3 dma rec", |
@@ -528,7 +532,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
528 | free_irq(DMA6_INTR_VECT, &ports[1]); | 532 | free_irq(DMA6_INTR_VECT, &ports[1]); |
529 | free_irq(DMA7_INTR_VECT, &ports[1]); | 533 | free_irq(DMA7_INTR_VECT, &ports[1]); |
530 | printk(KERN_CRIT "Can't allocate sync serial port 3 RX DMA channel"); | 534 | printk(KERN_CRIT "Can't allocate sync serial port 3 RX DMA channel"); |
531 | return -EBUSY; | 535 | goto out; |
532 | } | 536 | } |
533 | #endif | 537 | #endif |
534 | } | 538 | } |
@@ -554,7 +558,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
554 | "synchronous serial manual irq", | 558 | "synchronous serial manual irq", |
555 | &ports[0])) { | 559 | &ports[0])) { |
556 | printk("Can't allocate sync serial manual irq"); | 560 | printk("Can't allocate sync serial manual irq"); |
557 | return -EBUSY; | 561 | goto out; |
558 | } | 562 | } |
559 | } | 563 | } |
560 | #ifdef CONFIG_ETRAXFS | 564 | #ifdef CONFIG_ETRAXFS |
@@ -565,7 +569,7 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
565 | "synchronous serial manual irq", | 569 | "synchronous serial manual irq", |
566 | &ports[1])) { | 570 | &ports[1])) { |
567 | printk(KERN_CRIT "Can't allocate sync serial manual irq"); | 571 | printk(KERN_CRIT "Can't allocate sync serial manual irq"); |
568 | return -EBUSY; | 572 | goto out; |
569 | } | 573 | } |
570 | } | 574 | } |
571 | #endif | 575 | #endif |
@@ -578,7 +582,10 @@ static int sync_serial_open(struct inode *inode, struct file *file) | |||
578 | } /* port->init_irqs */ | 582 | } /* port->init_irqs */ |
579 | 583 | ||
580 | port->busy++; | 584 | port->busy++; |
581 | return 0; | 585 | ret = 0; |
586 | out: | ||
587 | unlock_kernel(); | ||
588 | return ret; | ||
582 | } | 589 | } |
583 | 590 | ||
584 | static int sync_serial_release(struct inode *inode, struct file *file) | 591 | static int sync_serial_release(struct inode *inode, struct file *file) |
diff --git a/arch/m68k/bvme6000/rtc.c b/arch/m68k/bvme6000/rtc.c index a812d03879f8..e8ac3f7d72df 100644 --- a/arch/m68k/bvme6000/rtc.c +++ b/arch/m68k/bvme6000/rtc.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
11 | #include <linux/miscdevice.h> | 11 | #include <linux/miscdevice.h> |
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | #include <linux/smp_lock.h> | ||
13 | #include <linux/ioport.h> | 14 | #include <linux/ioport.h> |
14 | #include <linux/capability.h> | 15 | #include <linux/capability.h> |
15 | #include <linux/fcntl.h> | 16 | #include <linux/fcntl.h> |
@@ -140,10 +141,14 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
140 | 141 | ||
141 | static int rtc_open(struct inode *inode, struct file *file) | 142 | static int rtc_open(struct inode *inode, struct file *file) |
142 | { | 143 | { |
143 | if(rtc_status) | 144 | lock_kernel(); |
145 | if(rtc_status) { | ||
146 | unlock_kernel(); | ||
144 | return -EBUSY; | 147 | return -EBUSY; |
148 | } | ||
145 | 149 | ||
146 | rtc_status = 1; | 150 | rtc_status = 1; |
151 | unlock_kernel(); | ||
147 | return 0; | 152 | return 0; |
148 | } | 153 | } |
149 | 154 | ||
diff --git a/arch/m68k/mvme16x/rtc.c b/arch/m68k/mvme16x/rtc.c index e341387787ab..432a9f13b2ed 100644 --- a/arch/m68k/mvme16x/rtc.c +++ b/arch/m68k/mvme16x/rtc.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
11 | #include <linux/miscdevice.h> | 11 | #include <linux/miscdevice.h> |
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | #include <linux/smp_lock.h> | ||
13 | #include <linux/ioport.h> | 14 | #include <linux/ioport.h> |
14 | #include <linux/capability.h> | 15 | #include <linux/capability.h> |
15 | #include <linux/fcntl.h> | 16 | #include <linux/fcntl.h> |
@@ -127,11 +128,14 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
127 | 128 | ||
128 | static int rtc_open(struct inode *inode, struct file *file) | 129 | static int rtc_open(struct inode *inode, struct file *file) |
129 | { | 130 | { |
131 | lock_kernel(); | ||
130 | if( !atomic_dec_and_test(&rtc_ready) ) | 132 | if( !atomic_dec_and_test(&rtc_ready) ) |
131 | { | 133 | { |
132 | atomic_inc( &rtc_ready ); | 134 | atomic_inc( &rtc_ready ); |
135 | unlock_kernel(); | ||
133 | return -EBUSY; | 136 | return -EBUSY; |
134 | } | 137 | } |
138 | unlock_kernel(); | ||
135 | 139 | ||
136 | return 0; | 140 | return 0; |
137 | } | 141 | } |
diff --git a/arch/mips/basler/excite/excite_iodev.c b/arch/mips/basler/excite/excite_iodev.c index 476d20e08d0e..a1e3526b4a94 100644 --- a/arch/mips/basler/excite/excite_iodev.c +++ b/arch/mips/basler/excite/excite_iodev.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/interrupt.h> | 26 | #include <linux/interrupt.h> |
27 | #include <linux/platform_device.h> | 27 | #include <linux/platform_device.h> |
28 | #include <linux/miscdevice.h> | 28 | #include <linux/miscdevice.h> |
29 | #include <linux/smp_lock.h> | ||
29 | 30 | ||
30 | #include "excite_iodev.h" | 31 | #include "excite_iodev.h" |
31 | 32 | ||
@@ -110,8 +111,14 @@ static int __exit iodev_remove(struct device *dev) | |||
110 | 111 | ||
111 | static int iodev_open(struct inode *i, struct file *f) | 112 | static int iodev_open(struct inode *i, struct file *f) |
112 | { | 113 | { |
113 | return request_irq(iodev_irq, iodev_irqhdl, IRQF_DISABLED, | 114 | int ret; |
115 | |||
116 | lock_kernel(); | ||
117 | ret = request_irq(iodev_irq, iodev_irqhdl, IRQF_DISABLED, | ||
114 | iodev_name, &miscdev); | 118 | iodev_name, &miscdev); |
119 | unlock_kernel(); | ||
120 | |||
121 | return ret; | ||
115 | } | 122 | } |
116 | 123 | ||
117 | static int iodev_release(struct inode *i, struct file *f) | 124 | static int iodev_release(struct inode *i, struct file *f) |
diff --git a/arch/mips/kernel/rtlx.c b/arch/mips/kernel/rtlx.c index b88f1c18ff4d..b55641961232 100644 --- a/arch/mips/kernel/rtlx.c +++ b/arch/mips/kernel/rtlx.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/vmalloc.h> | 28 | #include <linux/vmalloc.h> |
29 | #include <linux/elf.h> | 29 | #include <linux/elf.h> |
30 | #include <linux/seq_file.h> | 30 | #include <linux/seq_file.h> |
31 | #include <linux/smp_lock.h> | ||
31 | #include <linux/syscalls.h> | 32 | #include <linux/syscalls.h> |
32 | #include <linux/moduleloader.h> | 33 | #include <linux/moduleloader.h> |
33 | #include <linux/interrupt.h> | 34 | #include <linux/interrupt.h> |
@@ -392,8 +393,12 @@ out: | |||
392 | static int file_open(struct inode *inode, struct file *filp) | 393 | static int file_open(struct inode *inode, struct file *filp) |
393 | { | 394 | { |
394 | int minor = iminor(inode); | 395 | int minor = iminor(inode); |
396 | int err; | ||
395 | 397 | ||
396 | return rtlx_open(minor, (filp->f_flags & O_NONBLOCK) ? 0 : 1); | 398 | lock_kernel(); |
399 | err = rtlx_open(minor, (filp->f_flags & O_NONBLOCK) ? 0 : 1); | ||
400 | unlock_kernel(); | ||
401 | return err; | ||
397 | } | 402 | } |
398 | 403 | ||
399 | static int file_release(struct inode *inode, struct file *filp) | 404 | static int file_release(struct inode *inode, struct file *filp) |
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c index 2794501ff302..972b2d2b8401 100644 --- a/arch/mips/kernel/vpe.c +++ b/arch/mips/kernel/vpe.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/vmalloc.h> | 38 | #include <linux/vmalloc.h> |
39 | #include <linux/elf.h> | 39 | #include <linux/elf.h> |
40 | #include <linux/seq_file.h> | 40 | #include <linux/seq_file.h> |
41 | #include <linux/smp_lock.h> | ||
41 | #include <linux/syscalls.h> | 42 | #include <linux/syscalls.h> |
42 | #include <linux/moduleloader.h> | 43 | #include <linux/moduleloader.h> |
43 | #include <linux/interrupt.h> | 44 | #include <linux/interrupt.h> |
@@ -1050,17 +1051,20 @@ static int vpe_open(struct inode *inode, struct file *filp) | |||
1050 | enum vpe_state state; | 1051 | enum vpe_state state; |
1051 | struct vpe_notifications *not; | 1052 | struct vpe_notifications *not; |
1052 | struct vpe *v; | 1053 | struct vpe *v; |
1053 | int ret; | 1054 | int ret, err = 0; |
1054 | 1055 | ||
1056 | lock_kernel(); | ||
1055 | if (minor != iminor(inode)) { | 1057 | if (minor != iminor(inode)) { |
1056 | /* assume only 1 device at the moment. */ | 1058 | /* assume only 1 device at the moment. */ |
1057 | printk(KERN_WARNING "VPE loader: only vpe1 is supported\n"); | 1059 | printk(KERN_WARNING "VPE loader: only vpe1 is supported\n"); |
1058 | return -ENODEV; | 1060 | err = -ENODEV; |
1061 | goto out; | ||
1059 | } | 1062 | } |
1060 | 1063 | ||
1061 | if ((v = get_vpe(tclimit)) == NULL) { | 1064 | if ((v = get_vpe(tclimit)) == NULL) { |
1062 | printk(KERN_WARNING "VPE loader: unable to get vpe\n"); | 1065 | printk(KERN_WARNING "VPE loader: unable to get vpe\n"); |
1063 | return -ENODEV; | 1066 | err = -ENODEV; |
1067 | goto out; | ||
1064 | } | 1068 | } |
1065 | 1069 | ||
1066 | state = xchg(&v->state, VPE_STATE_INUSE); | 1070 | state = xchg(&v->state, VPE_STATE_INUSE); |
@@ -1100,6 +1104,8 @@ static int vpe_open(struct inode *inode, struct file *filp) | |||
1100 | v->shared_ptr = NULL; | 1104 | v->shared_ptr = NULL; |
1101 | v->__start = 0; | 1105 | v->__start = 0; |
1102 | 1106 | ||
1107 | out: | ||
1108 | unlock_kernel(); | ||
1103 | return 0; | 1109 | return 0; |
1104 | } | 1110 | } |
1105 | 1111 | ||
diff --git a/arch/mips/sibyte/common/sb_tbprof.c b/arch/mips/sibyte/common/sb_tbprof.c index 63b444eaf01e..28b012ab8dcb 100644 --- a/arch/mips/sibyte/common/sb_tbprof.c +++ b/arch/mips/sibyte/common/sb_tbprof.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/init.h> | 28 | #include <linux/init.h> |
29 | #include <linux/interrupt.h> | 29 | #include <linux/interrupt.h> |
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <linux/smp_lock.h> | ||
31 | #include <linux/vmalloc.h> | 32 | #include <linux/vmalloc.h> |
32 | #include <linux/fs.h> | 33 | #include <linux/fs.h> |
33 | #include <linux/errno.h> | 34 | #include <linux/errno.h> |
@@ -402,18 +403,26 @@ static int sbprof_zbprof_stop(void) | |||
402 | static int sbprof_tb_open(struct inode *inode, struct file *filp) | 403 | static int sbprof_tb_open(struct inode *inode, struct file *filp) |
403 | { | 404 | { |
404 | int minor; | 405 | int minor; |
406 | int err = 0; | ||
405 | 407 | ||
408 | lock_kernel(); | ||
406 | minor = iminor(inode); | 409 | minor = iminor(inode); |
407 | if (minor != 0) | 410 | if (minor != 0) { |
408 | return -ENODEV; | 411 | err = -ENODEV; |
412 | goto out; | ||
413 | } | ||
409 | 414 | ||
410 | if (xchg(&sbp.open, SB_OPENING) != SB_CLOSED) | 415 | if (xchg(&sbp.open, SB_OPENING) != SB_CLOSED) { |
411 | return -EBUSY; | 416 | err = -EBUSY; |
417 | goto out; | ||
418 | } | ||
412 | 419 | ||
413 | memset(&sbp, 0, sizeof(struct sbprof_tb)); | 420 | memset(&sbp, 0, sizeof(struct sbprof_tb)); |
414 | sbp.sbprof_tbbuf = vmalloc(MAX_TBSAMPLE_BYTES); | 421 | sbp.sbprof_tbbuf = vmalloc(MAX_TBSAMPLE_BYTES); |
415 | if (!sbp.sbprof_tbbuf) | 422 | if (!sbp.sbprof_tbbuf) { |
416 | return -ENOMEM; | 423 | err = -ENOMEM; |
424 | goto out; | ||
425 | } | ||
417 | memset(sbp.sbprof_tbbuf, 0, MAX_TBSAMPLE_BYTES); | 426 | memset(sbp.sbprof_tbbuf, 0, MAX_TBSAMPLE_BYTES); |
418 | init_waitqueue_head(&sbp.tb_sync); | 427 | init_waitqueue_head(&sbp.tb_sync); |
419 | init_waitqueue_head(&sbp.tb_read); | 428 | init_waitqueue_head(&sbp.tb_read); |
@@ -421,7 +430,9 @@ static int sbprof_tb_open(struct inode *inode, struct file *filp) | |||
421 | 430 | ||
422 | sbp.open = SB_OPEN; | 431 | sbp.open = SB_OPEN; |
423 | 432 | ||
424 | return 0; | 433 | out: |
434 | unlock_kernel(); | ||
435 | return err; | ||
425 | } | 436 | } |
426 | 437 | ||
427 | static int sbprof_tb_release(struct inode *inode, struct file *filp) | 438 | static int sbprof_tb_release(struct inode *inode, struct file *filp) |
diff --git a/arch/parisc/kernel/perf.c b/arch/parisc/kernel/perf.c index 89d6d5ad44b5..f696f57faa15 100644 --- a/arch/parisc/kernel/perf.c +++ b/arch/parisc/kernel/perf.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/init.h> | 46 | #include <linux/init.h> |
47 | #include <linux/proc_fs.h> | 47 | #include <linux/proc_fs.h> |
48 | #include <linux/miscdevice.h> | 48 | #include <linux/miscdevice.h> |
49 | #include <linux/smp_lock.h> | ||
49 | #include <linux/spinlock.h> | 50 | #include <linux/spinlock.h> |
50 | 51 | ||
51 | #include <asm/uaccess.h> | 52 | #include <asm/uaccess.h> |
@@ -260,13 +261,16 @@ printk("Preparing to start counters\n"); | |||
260 | */ | 261 | */ |
261 | static int perf_open(struct inode *inode, struct file *file) | 262 | static int perf_open(struct inode *inode, struct file *file) |
262 | { | 263 | { |
264 | lock_kernel(); | ||
263 | spin_lock(&perf_lock); | 265 | spin_lock(&perf_lock); |
264 | if (perf_enabled) { | 266 | if (perf_enabled) { |
265 | spin_unlock(&perf_lock); | 267 | spin_unlock(&perf_lock); |
268 | unlock_kernel(); | ||
266 | return -EBUSY; | 269 | return -EBUSY; |
267 | } | 270 | } |
268 | perf_enabled = 1; | 271 | perf_enabled = 1; |
269 | spin_unlock(&perf_lock); | 272 | spin_unlock(&perf_lock); |
273 | unlock_kernel(); | ||
270 | 274 | ||
271 | return 0; | 275 | return 0; |
272 | } | 276 | } |
diff --git a/arch/s390/crypto/prng.c b/arch/s390/crypto/prng.c index 6a4300b3ff52..eca724d229ec 100644 --- a/arch/s390/crypto/prng.c +++ b/arch/s390/crypto/prng.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <linux/fs.h> | 6 | #include <linux/fs.h> |
7 | #include <linux/init.h> | 7 | #include <linux/init.h> |
8 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
9 | #include <linux/smp_lock.h> | ||
9 | #include <linux/miscdevice.h> | 10 | #include <linux/miscdevice.h> |
10 | #include <linux/module.h> | 11 | #include <linux/module.h> |
11 | #include <linux/moduleparam.h> | 12 | #include <linux/moduleparam.h> |
@@ -48,6 +49,7 @@ static unsigned char parm_block[32] = { | |||
48 | 49 | ||
49 | static int prng_open(struct inode *inode, struct file *file) | 50 | static int prng_open(struct inode *inode, struct file *file) |
50 | { | 51 | { |
52 | cycle_kernel_lock(); | ||
51 | return nonseekable_open(inode, file); | 53 | return nonseekable_open(inode, file); |
52 | } | 54 | } |
53 | 55 | ||
diff --git a/arch/sh/boards/landisk/gio.c b/arch/sh/boards/landisk/gio.c index 17025080db35..0c15b0a50b99 100644 --- a/arch/sh/boards/landisk/gio.c +++ b/arch/sh/boards/landisk/gio.c | |||
@@ -14,6 +14,7 @@ | |||
14 | */ | 14 | */ |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
17 | #include <linux/smp_lock.h> | ||
17 | #include <linux/kdev_t.h> | 18 | #include <linux/kdev_t.h> |
18 | #include <linux/cdev.h> | 19 | #include <linux/cdev.h> |
19 | #include <linux/fs.h> | 20 | #include <linux/fs.h> |
@@ -32,17 +33,20 @@ static int openCnt; | |||
32 | static int gio_open(struct inode *inode, struct file *filp) | 33 | static int gio_open(struct inode *inode, struct file *filp) |
33 | { | 34 | { |
34 | int minor; | 35 | int minor; |
36 | int ret = -ENOENT; | ||
35 | 37 | ||
38 | lock_kernel(); | ||
36 | minor = MINOR(inode->i_rdev); | 39 | minor = MINOR(inode->i_rdev); |
37 | if (minor < DEVCOUNT) { | 40 | if (minor < DEVCOUNT) { |
38 | if (openCnt > 0) { | 41 | if (openCnt > 0) { |
39 | return -EALREADY; | 42 | ret = -EALREADY; |
40 | } else { | 43 | } else { |
41 | openCnt++; | 44 | openCnt++; |
42 | return 0; | 45 | ret = 0; |
43 | } | 46 | } |
44 | } | 47 | } |
45 | return -ENOENT; | 48 | unlock_kernel(); |
49 | return ret; | ||
46 | } | 50 | } |
47 | 51 | ||
48 | static int gio_close(struct inode *inode, struct file *filp) | 52 | static int gio_close(struct inode *inode, struct file *filp) |
diff --git a/arch/sparc/kernel/apc.c b/arch/sparc/kernel/apc.c index d06a405ca718..6707422c9847 100644 --- a/arch/sparc/kernel/apc.c +++ b/arch/sparc/kernel/apc.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/miscdevice.h> | 12 | #include <linux/miscdevice.h> |
13 | #include <linux/smp_lock.h> | ||
13 | #include <linux/pm.h> | 14 | #include <linux/pm.h> |
14 | 15 | ||
15 | #include <asm/io.h> | 16 | #include <asm/io.h> |
@@ -75,6 +76,7 @@ static inline void apc_free(void) | |||
75 | 76 | ||
76 | static int apc_open(struct inode *inode, struct file *f) | 77 | static int apc_open(struct inode *inode, struct file *f) |
77 | { | 78 | { |
79 | cycle_kernel_lock(); | ||
78 | return 0; | 80 | return 0; |
79 | } | 81 | } |
80 | 82 | ||
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c index e5d238970c7e..bedc4c159b1c 100644 --- a/arch/sparc64/kernel/time.c +++ b/arch/sparc64/kernel/time.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/errno.h> | 11 | #include <linux/errno.h> |
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/sched.h> | 13 | #include <linux/sched.h> |
14 | #include <linux/smp_lock.h> | ||
14 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
15 | #include <linux/param.h> | 16 | #include <linux/param.h> |
16 | #include <linux/string.h> | 17 | #include <linux/string.h> |
@@ -1659,10 +1660,14 @@ static int mini_rtc_ioctl(struct inode *inode, struct file *file, | |||
1659 | 1660 | ||
1660 | static int mini_rtc_open(struct inode *inode, struct file *file) | 1661 | static int mini_rtc_open(struct inode *inode, struct file *file) |
1661 | { | 1662 | { |
1662 | if (mini_rtc_status & RTC_IS_OPEN) | 1663 | lock_kernel(); |
1664 | if (mini_rtc_status & RTC_IS_OPEN) { | ||
1665 | unlock_kernel(); | ||
1663 | return -EBUSY; | 1666 | return -EBUSY; |
1667 | } | ||
1664 | 1668 | ||
1665 | mini_rtc_status |= RTC_IS_OPEN; | 1669 | mini_rtc_status |= RTC_IS_OPEN; |
1670 | unlock_kernel(); | ||
1666 | 1671 | ||
1667 | return 0; | 1672 | return 0; |
1668 | } | 1673 | } |
diff --git a/arch/um/drivers/harddog_kern.c b/arch/um/drivers/harddog_kern.c index a9ad4bd6d953..d332503fa1be 100644 --- a/arch/um/drivers/harddog_kern.c +++ b/arch/um/drivers/harddog_kern.c | |||
@@ -66,6 +66,7 @@ static int harddog_open(struct inode *inode, struct file *file) | |||
66 | int err = -EBUSY; | 66 | int err = -EBUSY; |
67 | char *sock = NULL; | 67 | char *sock = NULL; |
68 | 68 | ||
69 | lock_kernel(); | ||
69 | spin_lock(&lock); | 70 | spin_lock(&lock); |
70 | if(timer_alive) | 71 | if(timer_alive) |
71 | goto err; | 72 | goto err; |
@@ -82,9 +83,11 @@ static int harddog_open(struct inode *inode, struct file *file) | |||
82 | 83 | ||
83 | timer_alive = 1; | 84 | timer_alive = 1; |
84 | spin_unlock(&lock); | 85 | spin_unlock(&lock); |
86 | unlock_kernel(); | ||
85 | return nonseekable_open(inode, file); | 87 | return nonseekable_open(inode, file); |
86 | err: | 88 | err: |
87 | spin_unlock(&lock); | 89 | spin_unlock(&lock); |
90 | unlock_kernel(); | ||
88 | return err; | 91 | return err; |
89 | } | 92 | } |
90 | 93 | ||
diff --git a/arch/um/drivers/mmapper_kern.c b/arch/um/drivers/mmapper_kern.c index 67b2f55a602f..eb240323c40a 100644 --- a/arch/um/drivers/mmapper_kern.c +++ b/arch/um/drivers/mmapper_kern.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/miscdevice.h> | 16 | #include <linux/miscdevice.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/mm.h> | 18 | #include <linux/mm.h> |
19 | #include <linux/smp_lock.h> | ||
19 | #include <asm/uaccess.h> | 20 | #include <asm/uaccess.h> |
20 | #include "mem_user.h" | 21 | #include "mem_user.h" |
21 | 22 | ||
@@ -77,6 +78,7 @@ out: | |||
77 | 78 | ||
78 | static int mmapper_open(struct inode *inode, struct file *file) | 79 | static int mmapper_open(struct inode *inode, struct file *file) |
79 | { | 80 | { |
81 | cycle_kernel_lock(); | ||
80 | return 0; | 82 | return 0; |
81 | } | 83 | } |
82 | 84 | ||
diff --git a/arch/um/drivers/random.c b/arch/um/drivers/random.c index 4949044773ba..6eabb7022a2d 100644 --- a/arch/um/drivers/random.c +++ b/arch/um/drivers/random.c | |||
@@ -7,6 +7,7 @@ | |||
7 | * of the GNU General Public License, incorporated herein by reference. | 7 | * of the GNU General Public License, incorporated herein by reference. |
8 | */ | 8 | */ |
9 | #include <linux/sched.h> | 9 | #include <linux/sched.h> |
10 | #include <linux/smp_lock.h> | ||
10 | #include <linux/module.h> | 11 | #include <linux/module.h> |
11 | #include <linux/fs.h> | 12 | #include <linux/fs.h> |
12 | #include <linux/interrupt.h> | 13 | #include <linux/interrupt.h> |
@@ -33,6 +34,8 @@ static DECLARE_WAIT_QUEUE_HEAD(host_read_wait); | |||
33 | 34 | ||
34 | static int rng_dev_open (struct inode *inode, struct file *filp) | 35 | static int rng_dev_open (struct inode *inode, struct file *filp) |
35 | { | 36 | { |
37 | cycle_kernel_lock(); | ||
38 | |||
36 | /* enforce read-only access to this chrdev */ | 39 | /* enforce read-only access to this chrdev */ |
37 | if ((filp->f_mode & FMODE_READ) == 0) | 40 | if ((filp->f_mode & FMODE_READ) == 0) |
38 | return -EINVAL; | 41 | return -EINVAL; |
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c index 00e6d1370954..75cb5da4ea0a 100644 --- a/arch/x86/kernel/apm_32.c +++ b/arch/x86/kernel/apm_32.c | |||
@@ -204,6 +204,7 @@ | |||
204 | #include <linux/module.h> | 204 | #include <linux/module.h> |
205 | 205 | ||
206 | #include <linux/poll.h> | 206 | #include <linux/poll.h> |
207 | #include <linux/smp_lock.h> | ||
207 | #include <linux/types.h> | 208 | #include <linux/types.h> |
208 | #include <linux/stddef.h> | 209 | #include <linux/stddef.h> |
209 | #include <linux/timer.h> | 210 | #include <linux/timer.h> |
@@ -1549,10 +1550,12 @@ static int do_open(struct inode *inode, struct file *filp) | |||
1549 | { | 1550 | { |
1550 | struct apm_user *as; | 1551 | struct apm_user *as; |
1551 | 1552 | ||
1553 | lock_kernel(); | ||
1552 | as = kmalloc(sizeof(*as), GFP_KERNEL); | 1554 | as = kmalloc(sizeof(*as), GFP_KERNEL); |
1553 | if (as == NULL) { | 1555 | if (as == NULL) { |
1554 | printk(KERN_ERR "apm: cannot allocate struct of size %d bytes\n", | 1556 | printk(KERN_ERR "apm: cannot allocate struct of size %d bytes\n", |
1555 | sizeof(*as)); | 1557 | sizeof(*as)); |
1558 | unlock_kernel(); | ||
1556 | return -ENOMEM; | 1559 | return -ENOMEM; |
1557 | } | 1560 | } |
1558 | as->magic = APM_BIOS_MAGIC; | 1561 | as->magic = APM_BIOS_MAGIC; |
@@ -1574,6 +1577,7 @@ static int do_open(struct inode *inode, struct file *filp) | |||
1574 | user_list = as; | 1577 | user_list = as; |
1575 | spin_unlock(&user_list_lock); | 1578 | spin_unlock(&user_list_lock); |
1576 | filp->private_data = as; | 1579 | filp->private_data = as; |
1580 | unlock_kernel(); | ||
1577 | return 0; | 1581 | return 0; |
1578 | } | 1582 | } |
1579 | 1583 | ||
diff --git a/arch/x86/kernel/cpu/mcheck/mce_64.c b/arch/x86/kernel/cpu/mcheck/mce_64.c index 501ca1cea27d..987410745182 100644 --- a/arch/x86/kernel/cpu/mcheck/mce_64.c +++ b/arch/x86/kernel/cpu/mcheck/mce_64.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/types.h> | 9 | #include <linux/types.h> |
10 | #include <linux/kernel.h> | 10 | #include <linux/kernel.h> |
11 | #include <linux/sched.h> | 11 | #include <linux/sched.h> |
12 | #include <linux/smp_lock.h> | ||
12 | #include <linux/string.h> | 13 | #include <linux/string.h> |
13 | #include <linux/rcupdate.h> | 14 | #include <linux/rcupdate.h> |
14 | #include <linux/kallsyms.h> | 15 | #include <linux/kallsyms.h> |
@@ -532,10 +533,12 @@ static int open_exclu; /* already open exclusive? */ | |||
532 | 533 | ||
533 | static int mce_open(struct inode *inode, struct file *file) | 534 | static int mce_open(struct inode *inode, struct file *file) |
534 | { | 535 | { |
536 | lock_kernel(); | ||
535 | spin_lock(&mce_state_lock); | 537 | spin_lock(&mce_state_lock); |
536 | 538 | ||
537 | if (open_exclu || (open_count && (file->f_flags & O_EXCL))) { | 539 | if (open_exclu || (open_count && (file->f_flags & O_EXCL))) { |
538 | spin_unlock(&mce_state_lock); | 540 | spin_unlock(&mce_state_lock); |
541 | unlock_kernel(); | ||
539 | return -EBUSY; | 542 | return -EBUSY; |
540 | } | 543 | } |
541 | 544 | ||
@@ -544,6 +547,7 @@ static int mce_open(struct inode *inode, struct file *file) | |||
544 | open_count++; | 547 | open_count++; |
545 | 548 | ||
546 | spin_unlock(&mce_state_lock); | 549 | spin_unlock(&mce_state_lock); |
550 | unlock_kernel(); | ||
547 | 551 | ||
548 | return nonseekable_open(inode, file); | 552 | return nonseekable_open(inode, file); |
549 | } | 553 | } |
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c index daff52a62248..71f1c2654bec 100644 --- a/arch/x86/kernel/cpuid.c +++ b/arch/x86/kernel/cpuid.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/init.h> | 33 | #include <linux/init.h> |
34 | #include <linux/poll.h> | 34 | #include <linux/poll.h> |
35 | #include <linux/smp.h> | 35 | #include <linux/smp.h> |
36 | #include <linux/smp_lock.h> | ||
36 | #include <linux/major.h> | 37 | #include <linux/major.h> |
37 | #include <linux/fs.h> | 38 | #include <linux/fs.h> |
38 | #include <linux/smp_lock.h> | 39 | #include <linux/smp_lock.h> |
@@ -107,15 +108,23 @@ static ssize_t cpuid_read(struct file *file, char __user *buf, | |||
107 | 108 | ||
108 | static int cpuid_open(struct inode *inode, struct file *file) | 109 | static int cpuid_open(struct inode *inode, struct file *file) |
109 | { | 110 | { |
110 | unsigned int cpu = iminor(file->f_path.dentry->d_inode); | 111 | unsigned int cpu; |
111 | struct cpuinfo_x86 *c = &cpu_data(cpu); | 112 | struct cpuinfo_x86 *c; |
112 | 113 | int ret = 0; | |
113 | if (cpu >= NR_CPUS || !cpu_online(cpu)) | 114 | |
114 | return -ENXIO; /* No such CPU */ | 115 | lock_kernel(); |
116 | |||
117 | cpu = iminor(file->f_path.dentry->d_inode); | ||
118 | if (cpu >= NR_CPUS || !cpu_online(cpu)) { | ||
119 | ret = -ENXIO; /* No such CPU */ | ||
120 | goto out; | ||
121 | } | ||
122 | c = &cpu_data(cpu); | ||
115 | if (c->cpuid_level < 0) | 123 | if (c->cpuid_level < 0) |
116 | return -EIO; /* CPUID not supported */ | 124 | ret = -EIO; /* CPUID not supported */ |
117 | 125 | out: | |
118 | return 0; | 126 | unlock_kernel(); |
127 | return ret; | ||
119 | } | 128 | } |
120 | 129 | ||
121 | /* | 130 | /* |
diff --git a/arch/x86/kernel/microcode.c b/arch/x86/kernel/microcode.c index 9758fea87c5b..f47ba8156f3e 100644 --- a/arch/x86/kernel/microcode.c +++ b/arch/x86/kernel/microcode.c | |||
@@ -76,6 +76,7 @@ | |||
76 | #include <linux/kernel.h> | 76 | #include <linux/kernel.h> |
77 | #include <linux/init.h> | 77 | #include <linux/init.h> |
78 | #include <linux/sched.h> | 78 | #include <linux/sched.h> |
79 | #include <linux/smp_lock.h> | ||
79 | #include <linux/cpumask.h> | 80 | #include <linux/cpumask.h> |
80 | #include <linux/module.h> | 81 | #include <linux/module.h> |
81 | #include <linux/slab.h> | 82 | #include <linux/slab.h> |
@@ -423,6 +424,7 @@ out: | |||
423 | 424 | ||
424 | static int microcode_open (struct inode *unused1, struct file *unused2) | 425 | static int microcode_open (struct inode *unused1, struct file *unused2) |
425 | { | 426 | { |
427 | cycle_kernel_lock(); | ||
426 | return capable(CAP_SYS_RAWIO) ? 0 : -EPERM; | 428 | return capable(CAP_SYS_RAWIO) ? 0 : -EPERM; |
427 | } | 429 | } |
428 | 430 | ||
diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c index 1f3abe048e93..a153b3905f60 100644 --- a/arch/x86/kernel/msr.c +++ b/arch/x86/kernel/msr.c | |||
@@ -117,12 +117,20 @@ static int msr_open(struct inode *inode, struct file *file) | |||
117 | { | 117 | { |
118 | unsigned int cpu = iminor(file->f_path.dentry->d_inode); | 118 | unsigned int cpu = iminor(file->f_path.dentry->d_inode); |
119 | struct cpuinfo_x86 *c = &cpu_data(cpu); | 119 | struct cpuinfo_x86 *c = &cpu_data(cpu); |
120 | int ret = 0; | ||
120 | 121 | ||
121 | if (cpu >= NR_CPUS || !cpu_online(cpu)) | 122 | lock_kernel(); |
122 | return -ENXIO; /* No such CPU */ | 123 | cpu = iminor(file->f_path.dentry->d_inode); |
123 | if (!cpu_has(c, X86_FEATURE_MSR)) | ||
124 | return -EIO; /* MSR not supported */ | ||
125 | 124 | ||
125 | if (cpu >= NR_CPUS || !cpu_online(cpu)) { | ||
126 | ret = -ENXIO; /* No such CPU */ | ||
127 | goto out; | ||
128 | } | ||
129 | c = &cpu_data(cpu); | ||
130 | if (!cpu_has(c, X86_FEATURE_MSR)) | ||
131 | ret = -EIO; /* MSR not supported */ | ||
132 | out: | ||
133 | unlock_kernel(); | ||
126 | return 0; | 134 | return 0; |
127 | } | 135 | } |
128 | 136 | ||
diff --git a/block/bsg.c b/block/bsg.c index 93e757d7174b..0b3b282f0384 100644 --- a/block/bsg.c +++ b/block/bsg.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/uio.h> | 19 | #include <linux/uio.h> |
20 | #include <linux/idr.h> | 20 | #include <linux/idr.h> |
21 | #include <linux/bsg.h> | 21 | #include <linux/bsg.h> |
22 | #include <linux/smp_lock.h> | ||
22 | 23 | ||
23 | #include <scsi/scsi.h> | 24 | #include <scsi/scsi.h> |
24 | #include <scsi/scsi_ioctl.h> | 25 | #include <scsi/scsi_ioctl.h> |
@@ -851,7 +852,11 @@ static struct bsg_device *bsg_get_device(struct inode *inode, struct file *file) | |||
851 | 852 | ||
852 | static int bsg_open(struct inode *inode, struct file *file) | 853 | static int bsg_open(struct inode *inode, struct file *file) |
853 | { | 854 | { |
854 | struct bsg_device *bd = bsg_get_device(inode, file); | 855 | struct bsg_device *bd; |
856 | |||
857 | lock_kernel(); | ||
858 | bd = bsg_get_device(inode, file); | ||
859 | unlock_kernel(); | ||
855 | 860 | ||
856 | if (IS_ERR(bd)) | 861 | if (IS_ERR(bd)) |
857 | return PTR_ERR(bd); | 862 | return PTR_ERR(bd); |
diff --git a/drivers/block/aoe/aoechr.c b/drivers/block/aoe/aoechr.c index e8e60e7a2e70..d1de68a31920 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 | ||
12 | enum { | 13 | enum { |
@@ -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 ab86e23ddc69..9d92636350e5 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; | 549 | out: |
550 | unlock_kernel(); | ||
551 | return ret; | ||
542 | } | 552 | } |
543 | 553 | ||
544 | static int pg_release(struct inode *inode, struct file *file) | 554 | static int pg_release(struct inode *inode, struct file *file) |
diff --git a/drivers/block/paride/pt.c b/drivers/block/paride/pt.c index 27455ee1e9da..5c74c3574a5a 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 | ||
683 | out: | 687 | out: |
684 | atomic_inc(&tape->available); | 688 | atomic_inc(&tape->available); |
689 | unlock_kernel(); | ||
685 | return err; | 690 | return err; |
686 | } | 691 | } |
687 | 692 | ||
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c index 0638730a4a19..d97700aa54a9 100644 --- a/drivers/bluetooth/hci_vhci.c +++ b/drivers/bluetooth/hci_vhci.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
29 | #include <linux/init.h> | 29 | #include <linux/init.h> |
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <linux/smp_lock.h> | ||
31 | #include <linux/types.h> | 32 | #include <linux/types.h> |
32 | #include <linux/errno.h> | 33 | #include <linux/errno.h> |
33 | #include <linux/sched.h> | 34 | #include <linux/sched.h> |
@@ -263,9 +264,11 @@ static int vhci_open(struct inode *inode, struct file *file) | |||
263 | skb_queue_head_init(&data->readq); | 264 | skb_queue_head_init(&data->readq); |
264 | init_waitqueue_head(&data->read_wait); | 265 | init_waitqueue_head(&data->read_wait); |
265 | 266 | ||
267 | lock_kernel(); | ||
266 | hdev = hci_alloc_dev(); | 268 | hdev = hci_alloc_dev(); |
267 | if (!hdev) { | 269 | if (!hdev) { |
268 | kfree(data); | 270 | kfree(data); |
271 | unlock_kernel(); | ||
269 | return -ENOMEM; | 272 | return -ENOMEM; |
270 | } | 273 | } |
271 | 274 | ||
@@ -286,10 +289,12 @@ static int vhci_open(struct inode *inode, struct file *file) | |||
286 | BT_ERR("Can't register HCI device"); | 289 | BT_ERR("Can't register HCI device"); |
287 | kfree(data); | 290 | kfree(data); |
288 | hci_free_dev(hdev); | 291 | hci_free_dev(hdev); |
292 | unlock_kernel(); | ||
289 | return -EBUSY; | 293 | return -EBUSY; |
290 | } | 294 | } |
291 | 295 | ||
292 | file->private_data = data; | 296 | file->private_data = data; |
297 | unlock_kernel(); | ||
293 | 298 | ||
294 | return nonseekable_open(inode, file); | 299 | return nonseekable_open(inode, file); |
295 | } | 300 | } |
@@ -313,18 +318,21 @@ static int vhci_release(struct inode *inode, struct file *file) | |||
313 | static int vhci_fasync(int fd, struct file *file, int on) | 318 | static int vhci_fasync(int fd, struct file *file, int on) |
314 | { | 319 | { |
315 | struct vhci_data *data = file->private_data; | 320 | struct vhci_data *data = file->private_data; |
316 | int err; | 321 | int err = 0; |
317 | 322 | ||
323 | lock_kernel(); | ||
318 | err = fasync_helper(fd, file, on, &data->fasync); | 324 | err = fasync_helper(fd, file, on, &data->fasync); |
319 | if (err < 0) | 325 | if (err < 0) |
320 | return err; | 326 | goto out; |
321 | 327 | ||
322 | if (on) | 328 | if (on) |
323 | data->flags |= VHCI_FASYNC; | 329 | data->flags |= VHCI_FASYNC; |
324 | else | 330 | else |
325 | data->flags &= ~VHCI_FASYNC; | 331 | data->flags &= ~VHCI_FASYNC; |
326 | 332 | ||
327 | return 0; | 333 | out: |
334 | unlock_kernel(); | ||
335 | return err; | ||
328 | } | 336 | } |
329 | 337 | ||
330 | static const struct file_operations vhci_fops = { | 338 | static const struct file_operations vhci_fops = { |
diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c index e6cb1ab03e06..a96f3197e60f 100644 --- a/drivers/char/agp/frontend.c +++ b/drivers/char/agp/frontend.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/mm.h> | 39 | #include <linux/mm.h> |
40 | #include <linux/fs.h> | 40 | #include <linux/fs.h> |
41 | #include <linux/sched.h> | 41 | #include <linux/sched.h> |
42 | #include <linux/smp_lock.h> | ||
42 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
43 | #include <asm/pgtable.h> | 44 | #include <asm/pgtable.h> |
44 | #include "agp.h" | 45 | #include "agp.h" |
@@ -677,6 +678,7 @@ static int agp_open(struct inode *inode, struct file *file) | |||
677 | struct agp_client *client; | 678 | struct agp_client *client; |
678 | int rc = -ENXIO; | 679 | int rc = -ENXIO; |
679 | 680 | ||
681 | lock_kernel(); | ||
680 | mutex_lock(&(agp_fe.agp_mutex)); | 682 | mutex_lock(&(agp_fe.agp_mutex)); |
681 | 683 | ||
682 | if (minor != AGPGART_MINOR) | 684 | if (minor != AGPGART_MINOR) |
@@ -703,12 +705,14 @@ static int agp_open(struct inode *inode, struct file *file) | |||
703 | agp_insert_file_private(priv); | 705 | agp_insert_file_private(priv); |
704 | DBG("private=%p, client=%p", priv, client); | 706 | DBG("private=%p, client=%p", priv, client); |
705 | mutex_unlock(&(agp_fe.agp_mutex)); | 707 | mutex_unlock(&(agp_fe.agp_mutex)); |
708 | unlock_kernel(); | ||
706 | return 0; | 709 | return 0; |
707 | 710 | ||
708 | err_out_nomem: | 711 | err_out_nomem: |
709 | rc = -ENOMEM; | 712 | rc = -ENOMEM; |
710 | err_out: | 713 | err_out: |
711 | mutex_unlock(&(agp_fe.agp_mutex)); | 714 | mutex_unlock(&(agp_fe.agp_mutex)); |
715 | unlock_kernel(); | ||
712 | return rc; | 716 | return rc; |
713 | } | 717 | } |
714 | 718 | ||
diff --git a/drivers/char/apm-emulation.c b/drivers/char/apm-emulation.c index cdd876dbb2b0..da8a1658a273 100644 --- a/drivers/char/apm-emulation.c +++ b/drivers/char/apm-emulation.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/poll.h> | 14 | #include <linux/poll.h> |
15 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
16 | #include <linux/smp_lock.h> | ||
16 | #include <linux/proc_fs.h> | 17 | #include <linux/proc_fs.h> |
17 | #include <linux/seq_file.h> | 18 | #include <linux/seq_file.h> |
18 | #include <linux/miscdevice.h> | 19 | #include <linux/miscdevice.h> |
@@ -416,6 +417,7 @@ static int apm_open(struct inode * inode, struct file * filp) | |||
416 | { | 417 | { |
417 | struct apm_user *as; | 418 | struct apm_user *as; |
418 | 419 | ||
420 | lock_kernel(); | ||
419 | as = kzalloc(sizeof(*as), GFP_KERNEL); | 421 | as = kzalloc(sizeof(*as), GFP_KERNEL); |
420 | if (as) { | 422 | if (as) { |
421 | /* | 423 | /* |
@@ -435,6 +437,7 @@ static int apm_open(struct inode * inode, struct file * filp) | |||
435 | 437 | ||
436 | filp->private_data = as; | 438 | filp->private_data = as; |
437 | } | 439 | } |
440 | unlock_kernel(); | ||
438 | 441 | ||
439 | return as ? 0 : -ENOMEM; | 442 | return as ? 0 : -ENOMEM; |
440 | } | 443 | } |
diff --git a/drivers/char/briq_panel.c b/drivers/char/briq_panel.c index b6f2639f903d..d8cff909001c 100644 --- a/drivers/char/briq_panel.c +++ b/drivers/char/briq_panel.c | |||
@@ -6,6 +6,7 @@ | |||
6 | 6 | ||
7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
8 | 8 | ||
9 | #include <linux/smp_lock.h> | ||
9 | #include <linux/types.h> | 10 | #include <linux/types.h> |
10 | #include <linux/errno.h> | 11 | #include <linux/errno.h> |
11 | #include <linux/tty.h> | 12 | #include <linux/tty.h> |
@@ -67,11 +68,15 @@ static void set_led(char state) | |||
67 | 68 | ||
68 | static int briq_panel_open(struct inode *ino, struct file *filep) | 69 | static int briq_panel_open(struct inode *ino, struct file *filep) |
69 | { | 70 | { |
70 | /* enforce single access */ | 71 | lock_kernel(); |
71 | if (vfd_is_open) | 72 | /* enforce single access, vfd_is_open is protected by BKL */ |
73 | if (vfd_is_open) { | ||
74 | unlock_kernel(); | ||
72 | return -EBUSY; | 75 | return -EBUSY; |
76 | } | ||
73 | vfd_is_open = 1; | 77 | vfd_is_open = 1; |
74 | 78 | ||
79 | unlock_kernel(); | ||
75 | return 0; | 80 | return 0; |
76 | } | 81 | } |
77 | 82 | ||
diff --git a/drivers/char/cs5535_gpio.c b/drivers/char/cs5535_gpio.c index c0a4a0bb509e..04ba906b4880 100644 --- a/drivers/char/cs5535_gpio.c +++ b/drivers/char/cs5535_gpio.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/cdev.h> | 17 | #include <linux/cdev.h> |
18 | #include <linux/ioport.h> | 18 | #include <linux/ioport.h> |
19 | #include <linux/pci.h> | 19 | #include <linux/pci.h> |
20 | #include <linux/smp_lock.h> | ||
20 | #include <asm/uaccess.h> | 21 | #include <asm/uaccess.h> |
21 | #include <asm/io.h> | 22 | #include <asm/io.h> |
22 | 23 | ||
@@ -157,6 +158,7 @@ static int cs5535_gpio_open(struct inode *inode, struct file *file) | |||
157 | { | 158 | { |
158 | u32 m = iminor(inode); | 159 | u32 m = iminor(inode); |
159 | 160 | ||
161 | cycle_kernel_lock(); | ||
160 | /* the mask says which pins are usable by this driver */ | 162 | /* the mask says which pins are usable by this driver */ |
161 | if ((mask & (1 << m)) == 0) | 163 | if ((mask & (1 << m)) == 0) |
162 | return -EINVAL; | 164 | return -EINVAL; |
diff --git a/drivers/char/ds1286.c b/drivers/char/ds1286.c index ea35ab2c9909..fb584938c9c3 100644 --- a/drivers/char/ds1286.c +++ b/drivers/char/ds1286.c | |||
@@ -27,6 +27,7 @@ | |||
27 | * option) any later version. | 27 | * option) any later version. |
28 | */ | 28 | */ |
29 | #include <linux/ds1286.h> | 29 | #include <linux/ds1286.h> |
30 | #include <linux/smp_lock.h> | ||
30 | #include <linux/types.h> | 31 | #include <linux/types.h> |
31 | #include <linux/errno.h> | 32 | #include <linux/errno.h> |
32 | #include <linux/miscdevice.h> | 33 | #include <linux/miscdevice.h> |
@@ -252,6 +253,7 @@ static int ds1286_ioctl(struct inode *inode, struct file *file, | |||
252 | 253 | ||
253 | static int ds1286_open(struct inode *inode, struct file *file) | 254 | static int ds1286_open(struct inode *inode, struct file *file) |
254 | { | 255 | { |
256 | lock_kernel(); | ||
255 | spin_lock_irq(&ds1286_lock); | 257 | spin_lock_irq(&ds1286_lock); |
256 | 258 | ||
257 | if (ds1286_status & RTC_IS_OPEN) | 259 | if (ds1286_status & RTC_IS_OPEN) |
@@ -260,10 +262,12 @@ static int ds1286_open(struct inode *inode, struct file *file) | |||
260 | ds1286_status |= RTC_IS_OPEN; | 262 | ds1286_status |= RTC_IS_OPEN; |
261 | 263 | ||
262 | spin_unlock_irq(&ds1286_lock); | 264 | spin_unlock_irq(&ds1286_lock); |
265 | unlock_kernel(); | ||
263 | return 0; | 266 | return 0; |
264 | 267 | ||
265 | out_busy: | 268 | out_busy: |
266 | spin_lock_irq(&ds1286_lock); | 269 | spin_lock_irq(&ds1286_lock); |
270 | unlock_kernel(); | ||
267 | return -EBUSY; | 271 | return -EBUSY; |
268 | } | 272 | } |
269 | 273 | ||
diff --git a/drivers/char/ds1620.c b/drivers/char/ds1620.c index 334ad5bbe6b6..34275c6f1da2 100644 --- a/drivers/char/ds1620.c +++ b/drivers/char/ds1620.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include <linux/proc_fs.h> | 8 | #include <linux/proc_fs.h> |
9 | #include <linux/capability.h> | 9 | #include <linux/capability.h> |
10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
11 | #include <linux/smp_lock.h> | ||
11 | 12 | ||
12 | #include <asm/hardware.h> | 13 | #include <asm/hardware.h> |
13 | #include <asm/mach-types.h> | 14 | #include <asm/mach-types.h> |
@@ -208,6 +209,12 @@ static void ds1620_read_state(struct therm *therm) | |||
208 | therm->hi = cvt_9_to_int(ds1620_in(THERM_READ_TH, 9)); | 209 | therm->hi = cvt_9_to_int(ds1620_in(THERM_READ_TH, 9)); |
209 | } | 210 | } |
210 | 211 | ||
212 | static int ds1620_open(struct inode *inode, struct file *file) | ||
213 | { | ||
214 | cycle_kernel_lock(); | ||
215 | return nonseekable_open(inode, file); | ||
216 | } | ||
217 | |||
211 | static ssize_t | 218 | static ssize_t |
212 | ds1620_read(struct file *file, char __user *buf, size_t count, loff_t *ptr) | 219 | ds1620_read(struct file *file, char __user *buf, size_t count, loff_t *ptr) |
213 | { | 220 | { |
@@ -336,7 +343,7 @@ static struct proc_dir_entry *proc_therm_ds1620; | |||
336 | 343 | ||
337 | static const struct file_operations ds1620_fops = { | 344 | static const struct file_operations ds1620_fops = { |
338 | .owner = THIS_MODULE, | 345 | .owner = THIS_MODULE, |
339 | .open = nonseekable_open, | 346 | .open = ds1620_open, |
340 | .read = ds1620_read, | 347 | .read = ds1620_read, |
341 | .ioctl = ds1620_ioctl, | 348 | .ioctl = ds1620_ioctl, |
342 | }; | 349 | }; |
diff --git a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c index a69c65283260..7bf7485377e6 100644 --- a/drivers/char/dsp56k.c +++ b/drivers/char/dsp56k.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/mm.h> | 33 | #include <linux/mm.h> |
34 | #include <linux/init.h> | 34 | #include <linux/init.h> |
35 | #include <linux/device.h> | 35 | #include <linux/device.h> |
36 | #include <linux/smp_lock.h> | ||
36 | 37 | ||
37 | #include <asm/atarihw.h> | 38 | #include <asm/atarihw.h> |
38 | #include <asm/traps.h> | 39 | #include <asm/traps.h> |
@@ -436,13 +437,17 @@ static unsigned int dsp56k_poll(struct file *file, poll_table *wait) | |||
436 | static int dsp56k_open(struct inode *inode, struct file *file) | 437 | static int dsp56k_open(struct inode *inode, struct file *file) |
437 | { | 438 | { |
438 | int dev = iminor(inode) & 0x0f; | 439 | int dev = iminor(inode) & 0x0f; |
440 | int ret = 0; | ||
439 | 441 | ||
442 | lock_kernel(); | ||
440 | switch(dev) | 443 | switch(dev) |
441 | { | 444 | { |
442 | case DSP56K_DEV_56001: | 445 | case DSP56K_DEV_56001: |
443 | 446 | ||
444 | if (test_and_set_bit(0, &dsp56k.in_use)) | 447 | if (test_and_set_bit(0, &dsp56k.in_use)) { |
445 | return -EBUSY; | 448 | ret = -EBUSY; |
449 | goto out; | ||
450 | } | ||
446 | 451 | ||
447 | dsp56k.timeout = TIMEOUT; | 452 | dsp56k.timeout = TIMEOUT; |
448 | dsp56k.maxio = MAXIO; | 453 | dsp56k.maxio = MAXIO; |
@@ -458,10 +463,11 @@ static int dsp56k_open(struct inode *inode, struct file *file) | |||
458 | break; | 463 | break; |
459 | 464 | ||
460 | default: | 465 | default: |
461 | return -ENODEV; | 466 | ret = -ENODEV; |
462 | } | 467 | } |
463 | 468 | out: | |
464 | return 0; | 469 | unlock_kernel(); |
470 | return ret; | ||
465 | } | 471 | } |
466 | 472 | ||
467 | static int dsp56k_release(struct inode *inode, struct file *file) | 473 | static int dsp56k_release(struct inode *inode, struct file *file) |
diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c index abde6ddefe69..6b900b297cc6 100644 --- a/drivers/char/dtlk.c +++ b/drivers/char/dtlk.c | |||
@@ -56,6 +56,7 @@ | |||
56 | #include <linux/errno.h> /* for -EBUSY */ | 56 | #include <linux/errno.h> /* for -EBUSY */ |
57 | #include <linux/ioport.h> /* for request_region */ | 57 | #include <linux/ioport.h> /* for request_region */ |
58 | #include <linux/delay.h> /* for loops_per_jiffy */ | 58 | #include <linux/delay.h> /* for loops_per_jiffy */ |
59 | #include <linux/smp_lock.h> /* cycle_kernel_lock() */ | ||
59 | #include <asm/io.h> /* for inb_p, outb_p, inb, outb, etc. */ | 60 | #include <asm/io.h> /* for inb_p, outb_p, inb, outb, etc. */ |
60 | #include <asm/uaccess.h> /* for get_user, etc. */ | 61 | #include <asm/uaccess.h> /* for get_user, etc. */ |
61 | #include <linux/wait.h> /* for wait_queue */ | 62 | #include <linux/wait.h> /* for wait_queue */ |
@@ -288,10 +289,12 @@ static int dtlk_ioctl(struct inode *inode, | |||
288 | } | 289 | } |
289 | } | 290 | } |
290 | 291 | ||
292 | /* Note that nobody ever sets dtlk_busy... */ | ||
291 | static int dtlk_open(struct inode *inode, struct file *file) | 293 | static int dtlk_open(struct inode *inode, struct file *file) |
292 | { | 294 | { |
293 | TRACE_TEXT("(dtlk_open"); | 295 | TRACE_TEXT("(dtlk_open"); |
294 | 296 | ||
297 | cycle_kernel_lock(); | ||
295 | nonseekable_open(inode, file); | 298 | nonseekable_open(inode, file); |
296 | switch (iminor(inode)) { | 299 | switch (iminor(inode)) { |
297 | case DTLK_MINOR: | 300 | case DTLK_MINOR: |
diff --git a/drivers/char/efirtc.c b/drivers/char/efirtc.c index 49233f589874..d57ca3e4e534 100644 --- a/drivers/char/efirtc.c +++ b/drivers/char/efirtc.c | |||
@@ -28,6 +28,7 @@ | |||
28 | */ | 28 | */ |
29 | 29 | ||
30 | 30 | ||
31 | #include <linux/smp_lock.h> | ||
31 | #include <linux/types.h> | 32 | #include <linux/types.h> |
32 | #include <linux/errno.h> | 33 | #include <linux/errno.h> |
33 | #include <linux/miscdevice.h> | 34 | #include <linux/miscdevice.h> |
@@ -272,6 +273,7 @@ efi_rtc_open(struct inode *inode, struct file *file) | |||
272 | * We do accept multiple open files at the same time as we | 273 | * We do accept multiple open files at the same time as we |
273 | * synchronize on the per call operation. | 274 | * synchronize on the per call operation. |
274 | */ | 275 | */ |
276 | cycle_kernel_lock(); | ||
275 | return 0; | 277 | return 0; |
276 | } | 278 | } |
277 | 279 | ||
diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c index 69f0a2993af0..aac0985a572b 100644 --- a/drivers/char/genrtc.c +++ b/drivers/char/genrtc.c | |||
@@ -51,6 +51,7 @@ | |||
51 | #include <linux/init.h> | 51 | #include <linux/init.h> |
52 | #include <linux/poll.h> | 52 | #include <linux/poll.h> |
53 | #include <linux/proc_fs.h> | 53 | #include <linux/proc_fs.h> |
54 | #include <linux/smp_lock.h> | ||
54 | #include <linux/workqueue.h> | 55 | #include <linux/workqueue.h> |
55 | 56 | ||
56 | #include <asm/uaccess.h> | 57 | #include <asm/uaccess.h> |
@@ -338,12 +339,16 @@ static int gen_rtc_ioctl(struct inode *inode, struct file *file, | |||
338 | 339 | ||
339 | static int gen_rtc_open(struct inode *inode, struct file *file) | 340 | static int gen_rtc_open(struct inode *inode, struct file *file) |
340 | { | 341 | { |
341 | if (gen_rtc_status & RTC_IS_OPEN) | 342 | lock_kernel(); |
343 | if (gen_rtc_status & RTC_IS_OPEN) { | ||
344 | unlock_kernel(); | ||
342 | return -EBUSY; | 345 | return -EBUSY; |
346 | } | ||
343 | 347 | ||
344 | gen_rtc_status |= RTC_IS_OPEN; | 348 | gen_rtc_status |= RTC_IS_OPEN; |
345 | gen_rtc_irq_data = 0; | 349 | gen_rtc_irq_data = 0; |
346 | irq_active = 0; | 350 | irq_active = 0; |
351 | unlock_kernel(); | ||
347 | 352 | ||
348 | return 0; | 353 | return 0; |
349 | } | 354 | } |
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index e7fb0bca3667..fb0a85a1eb36 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/interrupt.h> | 14 | #include <linux/interrupt.h> |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/smp_lock.h> | ||
17 | #include <linux/types.h> | 18 | #include <linux/types.h> |
18 | #include <linux/miscdevice.h> | 19 | #include <linux/miscdevice.h> |
19 | #include <linux/major.h> | 20 | #include <linux/major.h> |
@@ -193,6 +194,7 @@ static int hpet_open(struct inode *inode, struct file *file) | |||
193 | if (file->f_mode & FMODE_WRITE) | 194 | if (file->f_mode & FMODE_WRITE) |
194 | return -EINVAL; | 195 | return -EINVAL; |
195 | 196 | ||
197 | lock_kernel(); | ||
196 | spin_lock_irq(&hpet_lock); | 198 | spin_lock_irq(&hpet_lock); |
197 | 199 | ||
198 | for (devp = NULL, hpetp = hpets; hpetp && !devp; hpetp = hpetp->hp_next) | 200 | 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) | |||
207 | 209 | ||
208 | if (!devp) { | 210 | if (!devp) { |
209 | spin_unlock_irq(&hpet_lock); | 211 | spin_unlock_irq(&hpet_lock); |
212 | unlock_kernel(); | ||
210 | return -EBUSY; | 213 | return -EBUSY; |
211 | } | 214 | } |
212 | 215 | ||
@@ -214,6 +217,7 @@ static int hpet_open(struct inode *inode, struct file *file) | |||
214 | devp->hd_irqdata = 0; | 217 | devp->hd_irqdata = 0; |
215 | devp->hd_flags |= HPET_OPEN; | 218 | devp->hd_flags |= HPET_OPEN; |
216 | spin_unlock_irq(&hpet_lock); | 219 | spin_unlock_irq(&hpet_lock); |
220 | unlock_kernel(); | ||
217 | 221 | ||
218 | return 0; | 222 | return 0; |
219 | } | 223 | } |
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c index 662d60e44e9a..e5d583c84e4f 100644 --- a/drivers/char/hw_random/core.c +++ b/drivers/char/hw_random/core.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
38 | #include <linux/fs.h> | 38 | #include <linux/fs.h> |
39 | #include <linux/sched.h> | 39 | #include <linux/sched.h> |
40 | #include <linux/smp_lock.h> | ||
40 | #include <linux/init.h> | 41 | #include <linux/init.h> |
41 | #include <linux/miscdevice.h> | 42 | #include <linux/miscdevice.h> |
42 | #include <linux/delay.h> | 43 | #include <linux/delay.h> |
@@ -86,6 +87,7 @@ static int rng_dev_open(struct inode *inode, struct file *filp) | |||
86 | return -EINVAL; | 87 | return -EINVAL; |
87 | if (filp->f_mode & FMODE_WRITE) | 88 | if (filp->f_mode & FMODE_WRITE) |
88 | return -EINVAL; | 89 | return -EINVAL; |
90 | cycle_kernel_lock(); | ||
89 | return 0; | 91 | return 0; |
90 | } | 92 | } |
91 | 93 | ||
diff --git a/drivers/char/ip2/ip2main.c b/drivers/char/ip2/ip2main.c index c12cf8fc4be0..61b6fe4156bb 100644 --- a/drivers/char/ip2/ip2main.c +++ b/drivers/char/ip2/ip2main.c | |||
@@ -98,6 +98,7 @@ | |||
98 | #include <linux/major.h> | 98 | #include <linux/major.h> |
99 | #include <linux/wait.h> | 99 | #include <linux/wait.h> |
100 | #include <linux/device.h> | 100 | #include <linux/device.h> |
101 | #include <linux/smp_lock.h> | ||
101 | 102 | ||
102 | #include <linux/tty.h> | 103 | #include <linux/tty.h> |
103 | #include <linux/tty_flip.h> | 104 | #include <linux/tty_flip.h> |
@@ -2908,42 +2909,11 @@ ip2_ipl_ioctl ( struct inode *pInode, struct file *pFile, UINT cmd, ULONG arg ) | |||
2908 | static int | 2909 | static int |
2909 | ip2_ipl_open( struct inode *pInode, struct file *pFile ) | 2910 | ip2_ipl_open( struct inode *pInode, struct file *pFile ) |
2910 | { | 2911 | { |
2911 | unsigned int iplminor = iminor(pInode); | ||
2912 | i2eBordStrPtr pB; | ||
2913 | i2ChanStrPtr pCh; | ||
2914 | 2912 | ||
2915 | #ifdef IP2DEBUG_IPL | 2913 | #ifdef IP2DEBUG_IPL |
2916 | printk (KERN_DEBUG "IP2IPL: open\n" ); | 2914 | printk (KERN_DEBUG "IP2IPL: open\n" ); |
2917 | #endif | 2915 | #endif |
2918 | 2916 | cycle_kernel_lock(); | |
2919 | switch(iplminor) { | ||
2920 | // These are the IPL devices | ||
2921 | case 0: | ||
2922 | case 4: | ||
2923 | case 8: | ||
2924 | case 12: | ||
2925 | break; | ||
2926 | |||
2927 | // These are the status devices | ||
2928 | case 1: | ||
2929 | case 5: | ||
2930 | case 9: | ||
2931 | case 13: | ||
2932 | break; | ||
2933 | |||
2934 | // These are the debug devices | ||
2935 | case 2: | ||
2936 | case 6: | ||
2937 | case 10: | ||
2938 | case 14: | ||
2939 | pB = i2BoardPtrTable[iplminor / 4]; | ||
2940 | pCh = (i2ChanStrPtr) pB->i2eChannelPtr; | ||
2941 | break; | ||
2942 | |||
2943 | // This is the trace device | ||
2944 | case 3: | ||
2945 | break; | ||
2946 | } | ||
2947 | return 0; | 2917 | return 0; |
2948 | } | 2918 | } |
2949 | 2919 | ||
diff --git a/drivers/char/ip27-rtc.c b/drivers/char/ip27-rtc.c index 86e6538a77b0..ec9d0443d92c 100644 --- a/drivers/char/ip27-rtc.c +++ b/drivers/char/ip27-rtc.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/bcd.h> | 27 | #include <linux/bcd.h> |
28 | #include <linux/module.h> | 28 | #include <linux/module.h> |
29 | #include <linux/kernel.h> | 29 | #include <linux/kernel.h> |
30 | #include <linux/smp_lock.h> | ||
30 | #include <linux/types.h> | 31 | #include <linux/types.h> |
31 | #include <linux/miscdevice.h> | 32 | #include <linux/miscdevice.h> |
32 | #include <linux/ioport.h> | 33 | #include <linux/ioport.h> |
@@ -163,15 +164,18 @@ static long rtc_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
163 | 164 | ||
164 | static int rtc_open(struct inode *inode, struct file *file) | 165 | static int rtc_open(struct inode *inode, struct file *file) |
165 | { | 166 | { |
167 | lock_kernel(); | ||
166 | spin_lock_irq(&rtc_lock); | 168 | spin_lock_irq(&rtc_lock); |
167 | 169 | ||
168 | if (rtc_status & RTC_IS_OPEN) { | 170 | if (rtc_status & RTC_IS_OPEN) { |
169 | spin_unlock_irq(&rtc_lock); | 171 | spin_unlock_irq(&rtc_lock); |
172 | unlock_kernel(); | ||
170 | return -EBUSY; | 173 | return -EBUSY; |
171 | } | 174 | } |
172 | 175 | ||
173 | rtc_status |= RTC_IS_OPEN; | 176 | rtc_status |= RTC_IS_OPEN; |
174 | spin_unlock_irq(&rtc_lock); | 177 | spin_unlock_irq(&rtc_lock); |
178 | unlock_kernel(); | ||
175 | 179 | ||
176 | return 0; | 180 | return 0; |
177 | } | 181 | } |
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c index 0246a2b8ce48..c11a40483459 100644 --- a/drivers/char/ipmi/ipmi_devintf.c +++ b/drivers/char/ipmi/ipmi_devintf.c | |||
@@ -43,6 +43,7 @@ | |||
43 | #include <linux/init.h> | 43 | #include <linux/init.h> |
44 | #include <linux/device.h> | 44 | #include <linux/device.h> |
45 | #include <linux/compat.h> | 45 | #include <linux/compat.h> |
46 | #include <linux/smp_lock.h> | ||
46 | 47 | ||
47 | struct ipmi_file_private | 48 | struct ipmi_file_private |
48 | { | 49 | { |
@@ -100,7 +101,9 @@ static int ipmi_fasync(int fd, struct file *file, int on) | |||
100 | struct ipmi_file_private *priv = file->private_data; | 101 | struct ipmi_file_private *priv = file->private_data; |
101 | int result; | 102 | int result; |
102 | 103 | ||
104 | lock_kernel(); /* could race against open() otherwise */ | ||
103 | result = fasync_helper(fd, file, on, &priv->fasync_queue); | 105 | result = fasync_helper(fd, file, on, &priv->fasync_queue); |
106 | unlock_kernel(); | ||
104 | 107 | ||
105 | return (result); | 108 | return (result); |
106 | } | 109 | } |
@@ -121,6 +124,7 @@ static int ipmi_open(struct inode *inode, struct file *file) | |||
121 | if (!priv) | 124 | if (!priv) |
122 | return -ENOMEM; | 125 | return -ENOMEM; |
123 | 126 | ||
127 | lock_kernel(); | ||
124 | priv->file = file; | 128 | priv->file = file; |
125 | 129 | ||
126 | rv = ipmi_create_user(if_num, | 130 | rv = ipmi_create_user(if_num, |
@@ -129,7 +133,7 @@ static int ipmi_open(struct inode *inode, struct file *file) | |||
129 | &(priv->user)); | 133 | &(priv->user)); |
130 | if (rv) { | 134 | if (rv) { |
131 | kfree(priv); | 135 | kfree(priv); |
132 | return rv; | 136 | goto out; |
133 | } | 137 | } |
134 | 138 | ||
135 | file->private_data = priv; | 139 | file->private_data = priv; |
@@ -144,7 +148,9 @@ static int ipmi_open(struct inode *inode, struct file *file) | |||
144 | priv->default_retries = -1; | 148 | priv->default_retries = -1; |
145 | priv->default_retry_time_ms = 0; | 149 | priv->default_retry_time_ms = 0; |
146 | 150 | ||
147 | return 0; | 151 | out: |
152 | unlock_kernel(); | ||
153 | return rv; | ||
148 | } | 154 | } |
149 | 155 | ||
150 | static int ipmi_release(struct inode *inode, struct file *file) | 156 | static int ipmi_release(struct inode *inode, struct file *file) |
diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c index 0e6df289cb46..235fab0bdf79 100644 --- a/drivers/char/ipmi/ipmi_watchdog.c +++ b/drivers/char/ipmi/ipmi_watchdog.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/moduleparam.h> | 35 | #include <linux/moduleparam.h> |
36 | #include <linux/ipmi.h> | 36 | #include <linux/ipmi.h> |
37 | #include <linux/ipmi_smi.h> | 37 | #include <linux/ipmi_smi.h> |
38 | #include <linux/smp_lock.h> | ||
38 | #include <linux/watchdog.h> | 39 | #include <linux/watchdog.h> |
39 | #include <linux/miscdevice.h> | 40 | #include <linux/miscdevice.h> |
40 | #include <linux/init.h> | 41 | #include <linux/init.h> |
@@ -818,6 +819,8 @@ static int ipmi_open(struct inode *ino, struct file *filep) | |||
818 | if (test_and_set_bit(0, &ipmi_wdog_open)) | 819 | if (test_and_set_bit(0, &ipmi_wdog_open)) |
819 | return -EBUSY; | 820 | return -EBUSY; |
820 | 821 | ||
822 | cycle_kernel_lock(); | ||
823 | |||
821 | /* | 824 | /* |
822 | * Don't start the timer now, let it start on the | 825 | * Don't start the timer now, let it start on the |
823 | * first heartbeat. | 826 | * first heartbeat. |
diff --git a/drivers/char/lcd.c b/drivers/char/lcd.c index 4fe9206f84de..1c29b20e4f4c 100644 --- a/drivers/char/lcd.c +++ b/drivers/char/lcd.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/mc146818rtc.h> | 20 | #include <linux/mc146818rtc.h> |
21 | #include <linux/netdevice.h> | 21 | #include <linux/netdevice.h> |
22 | #include <linux/sched.h> | 22 | #include <linux/sched.h> |
23 | #include <linux/smp_lock.h> | ||
23 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
24 | 25 | ||
25 | #include <asm/io.h> | 26 | #include <asm/io.h> |
@@ -414,6 +415,8 @@ static int lcd_ioctl(struct inode *inode, struct file *file, | |||
414 | 415 | ||
415 | static int lcd_open(struct inode *inode, struct file *file) | 416 | static int lcd_open(struct inode *inode, struct file *file) |
416 | { | 417 | { |
418 | cycle_kernel_lock(); | ||
419 | |||
417 | if (!lcd_present) | 420 | if (!lcd_present) |
418 | return -ENXIO; | 421 | return -ENXIO; |
419 | else | 422 | else |
diff --git a/drivers/char/lp.c b/drivers/char/lp.c index 60ac642752be..71abb4c33aa2 100644 --- a/drivers/char/lp.c +++ b/drivers/char/lp.c | |||
@@ -126,6 +126,7 @@ | |||
126 | #include <linux/device.h> | 126 | #include <linux/device.h> |
127 | #include <linux/wait.h> | 127 | #include <linux/wait.h> |
128 | #include <linux/jiffies.h> | 128 | #include <linux/jiffies.h> |
129 | #include <linux/smp_lock.h> | ||
129 | 130 | ||
130 | #include <linux/parport.h> | 131 | #include <linux/parport.h> |
131 | #undef LP_STATS | 132 | #undef LP_STATS |
@@ -489,14 +490,21 @@ static ssize_t lp_read(struct file * file, char __user * buf, | |||
489 | static int lp_open(struct inode * inode, struct file * file) | 490 | static int lp_open(struct inode * inode, struct file * file) |
490 | { | 491 | { |
491 | unsigned int minor = iminor(inode); | 492 | unsigned int minor = iminor(inode); |
493 | int ret = 0; | ||
492 | 494 | ||
493 | if (minor >= LP_NO) | 495 | lock_kernel(); |
494 | return -ENXIO; | 496 | if (minor >= LP_NO) { |
495 | if ((LP_F(minor) & LP_EXIST) == 0) | 497 | ret = -ENXIO; |
496 | return -ENXIO; | 498 | goto out; |
497 | if (test_and_set_bit(LP_BUSY_BIT_POS, &LP_F(minor))) | 499 | } |
498 | return -EBUSY; | 500 | if ((LP_F(minor) & LP_EXIST) == 0) { |
499 | 501 | ret = -ENXIO; | |
502 | goto out; | ||
503 | } | ||
504 | if (test_and_set_bit(LP_BUSY_BIT_POS, &LP_F(minor))) { | ||
505 | ret = -EBUSY; | ||
506 | goto out; | ||
507 | } | ||
500 | /* If ABORTOPEN is set and the printer is offline or out of paper, | 508 | /* If ABORTOPEN is set and the printer is offline or out of paper, |
501 | we may still want to open it to perform ioctl()s. Therefore we | 509 | we may still want to open it to perform ioctl()s. Therefore we |
502 | have commandeered O_NONBLOCK, even though it is being used in | 510 | 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) | |||
510 | if (status & LP_POUTPA) { | 518 | if (status & LP_POUTPA) { |
511 | printk(KERN_INFO "lp%d out of paper\n", minor); | 519 | printk(KERN_INFO "lp%d out of paper\n", minor); |
512 | LP_F(minor) &= ~LP_BUSY; | 520 | LP_F(minor) &= ~LP_BUSY; |
513 | return -ENOSPC; | 521 | ret = -ENOSPC; |
522 | goto out; | ||
514 | } else if (!(status & LP_PSELECD)) { | 523 | } else if (!(status & LP_PSELECD)) { |
515 | printk(KERN_INFO "lp%d off-line\n", minor); | 524 | printk(KERN_INFO "lp%d off-line\n", minor); |
516 | LP_F(minor) &= ~LP_BUSY; | 525 | LP_F(minor) &= ~LP_BUSY; |
517 | return -EIO; | 526 | ret = -EIO; |
527 | goto out; | ||
518 | } else if (!(status & LP_PERRORP)) { | 528 | } else if (!(status & LP_PERRORP)) { |
519 | printk(KERN_ERR "lp%d printer error\n", minor); | 529 | printk(KERN_ERR "lp%d printer error\n", minor); |
520 | LP_F(minor) &= ~LP_BUSY; | 530 | LP_F(minor) &= ~LP_BUSY; |
521 | return -EIO; | 531 | ret = -EIO; |
532 | goto out; | ||
522 | } | 533 | } |
523 | } | 534 | } |
524 | lp_table[minor].lp_buffer = kmalloc(LP_BUFFER_SIZE, GFP_KERNEL); | 535 | lp_table[minor].lp_buffer = kmalloc(LP_BUFFER_SIZE, GFP_KERNEL); |
525 | if (!lp_table[minor].lp_buffer) { | 536 | if (!lp_table[minor].lp_buffer) { |
526 | LP_F(minor) &= ~LP_BUSY; | 537 | LP_F(minor) &= ~LP_BUSY; |
527 | return -ENOMEM; | 538 | ret = -ENOMEM; |
539 | goto out; | ||
528 | } | 540 | } |
529 | /* Determine if the peripheral supports ECP mode */ | 541 | /* Determine if the peripheral supports ECP mode */ |
530 | lp_claim_parport_or_block (&lp_table[minor]); | 542 | lp_claim_parport_or_block (&lp_table[minor]); |
@@ -540,7 +552,9 @@ static int lp_open(struct inode * inode, struct file * file) | |||
540 | parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); | 552 | parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); |
541 | lp_release_parport (&lp_table[minor]); | 553 | lp_release_parport (&lp_table[minor]); |
542 | lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; | 554 | lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; |
543 | return 0; | 555 | out: |
556 | unlock_kernel(); | ||
557 | return ret; | ||
544 | } | 558 | } |
545 | 559 | ||
546 | static int lp_release(struct inode * inode, struct file * file) | 560 | static int lp_release(struct inode * inode, struct file * file) |
diff --git a/drivers/char/mbcs.c b/drivers/char/mbcs.c index f4716ad7348a..acd8e9ed474a 100644 --- a/drivers/char/mbcs.c +++ b/drivers/char/mbcs.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/mm.h> | 24 | #include <linux/mm.h> |
25 | #include <linux/uio.h> | 25 | #include <linux/uio.h> |
26 | #include <linux/mutex.h> | 26 | #include <linux/mutex.h> |
27 | #include <linux/smp_lock.h> | ||
27 | #include <asm/io.h> | 28 | #include <asm/io.h> |
28 | #include <asm/uaccess.h> | 29 | #include <asm/uaccess.h> |
29 | #include <asm/system.h> | 30 | #include <asm/system.h> |
@@ -382,15 +383,19 @@ static int mbcs_open(struct inode *ip, struct file *fp) | |||
382 | struct mbcs_soft *soft; | 383 | struct mbcs_soft *soft; |
383 | int minor; | 384 | int minor; |
384 | 385 | ||
386 | lock_kernel(); | ||
385 | minor = iminor(ip); | 387 | minor = iminor(ip); |
386 | 388 | ||
389 | /* Nothing protects access to this list... */ | ||
387 | list_for_each_entry(soft, &soft_list, list) { | 390 | list_for_each_entry(soft, &soft_list, list) { |
388 | if (soft->nasid == minor) { | 391 | if (soft->nasid == minor) { |
389 | fp->private_data = soft->cxdev; | 392 | fp->private_data = soft->cxdev; |
393 | unlock_kernel(); | ||
390 | return 0; | 394 | return 0; |
391 | } | 395 | } |
392 | } | 396 | } |
393 | 397 | ||
398 | unlock_kernel(); | ||
394 | return -ENODEV; | 399 | return -ENODEV; |
395 | } | 400 | } |
396 | 401 | ||
diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 934ffafedaea..070e22e8ea9e 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/bootmem.h> | 26 | #include <linux/bootmem.h> |
27 | #include <linux/splice.h> | 27 | #include <linux/splice.h> |
28 | #include <linux/pfn.h> | 28 | #include <linux/pfn.h> |
29 | #include <linux/smp_lock.h> | ||
29 | 30 | ||
30 | #include <asm/uaccess.h> | 31 | #include <asm/uaccess.h> |
31 | #include <asm/io.h> | 32 | #include <asm/io.h> |
@@ -889,6 +890,9 @@ static const struct file_operations kmsg_fops = { | |||
889 | 890 | ||
890 | static int memory_open(struct inode * inode, struct file * filp) | 891 | static int memory_open(struct inode * inode, struct file * filp) |
891 | { | 892 | { |
893 | int ret = 0; | ||
894 | |||
895 | lock_kernel(); | ||
892 | switch (iminor(inode)) { | 896 | switch (iminor(inode)) { |
893 | case 1: | 897 | case 1: |
894 | filp->f_op = &mem_fops; | 898 | filp->f_op = &mem_fops; |
@@ -932,11 +936,13 @@ static int memory_open(struct inode * inode, struct file * filp) | |||
932 | break; | 936 | break; |
933 | #endif | 937 | #endif |
934 | default: | 938 | default: |
939 | unlock_kernel(); | ||
935 | return -ENXIO; | 940 | return -ENXIO; |
936 | } | 941 | } |
937 | if (filp->f_op && filp->f_op->open) | 942 | if (filp->f_op && filp->f_op->open) |
938 | return filp->f_op->open(inode,filp); | 943 | ret = filp->f_op->open(inode,filp); |
939 | return 0; | 944 | unlock_kernel(); |
945 | return ret; | ||
940 | } | 946 | } |
941 | 947 | ||
942 | static const struct file_operations memory_fops = { | 948 | static const struct file_operations memory_fops = { |
diff --git a/drivers/char/misc.c b/drivers/char/misc.c index eaace0db0ff4..6e1563c3d30a 100644 --- a/drivers/char/misc.c +++ b/drivers/char/misc.c | |||
@@ -49,6 +49,7 @@ | |||
49 | #include <linux/device.h> | 49 | #include <linux/device.h> |
50 | #include <linux/tty.h> | 50 | #include <linux/tty.h> |
51 | #include <linux/kmod.h> | 51 | #include <linux/kmod.h> |
52 | #include <linux/smp_lock.h> | ||
52 | 53 | ||
53 | /* | 54 | /* |
54 | * Head entry for the doubly linked miscdevice list | 55 | * Head entry for the doubly linked miscdevice list |
@@ -118,6 +119,7 @@ static int misc_open(struct inode * inode, struct file * file) | |||
118 | int err = -ENODEV; | 119 | int err = -ENODEV; |
119 | const struct file_operations *old_fops, *new_fops = NULL; | 120 | const struct file_operations *old_fops, *new_fops = NULL; |
120 | 121 | ||
122 | lock_kernel(); | ||
121 | mutex_lock(&misc_mtx); | 123 | mutex_lock(&misc_mtx); |
122 | 124 | ||
123 | list_for_each_entry(c, &misc_list, list) { | 125 | list_for_each_entry(c, &misc_list, list) { |
@@ -155,6 +157,7 @@ static int misc_open(struct inode * inode, struct file * file) | |||
155 | fops_put(old_fops); | 157 | fops_put(old_fops); |
156 | fail: | 158 | fail: |
157 | mutex_unlock(&misc_mtx); | 159 | mutex_unlock(&misc_mtx); |
160 | unlock_kernel(); | ||
158 | return err; | 161 | return err; |
159 | } | 162 | } |
160 | 163 | ||
diff --git a/drivers/char/mwave/mwavedd.c b/drivers/char/mwave/mwavedd.c index 8d14823b0514..50243fcd87e8 100644 --- a/drivers/char/mwave/mwavedd.c +++ b/drivers/char/mwave/mwavedd.c | |||
@@ -56,6 +56,7 @@ | |||
56 | #include <linux/serial.h> | 56 | #include <linux/serial.h> |
57 | #include <linux/sched.h> | 57 | #include <linux/sched.h> |
58 | #include <linux/spinlock.h> | 58 | #include <linux/spinlock.h> |
59 | #include <linux/smp_lock.h> | ||
59 | #include <linux/delay.h> | 60 | #include <linux/delay.h> |
60 | #include <linux/serial_8250.h> | 61 | #include <linux/serial_8250.h> |
61 | #include "smapi.h" | 62 | #include "smapi.h" |
@@ -100,6 +101,7 @@ static int mwave_open(struct inode *inode, struct file *file) | |||
100 | PRINTK_2(TRACE_MWAVE, | 101 | PRINTK_2(TRACE_MWAVE, |
101 | "mwavedd::mwave_open, exit return retval %x\n", retval); | 102 | "mwavedd::mwave_open, exit return retval %x\n", retval); |
102 | 103 | ||
104 | cycle_kernel_lock(); | ||
103 | return retval; | 105 | return retval; |
104 | } | 106 | } |
105 | 107 | ||
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c index 98dec380af49..197cd7a0c332 100644 --- a/drivers/char/nvram.c +++ b/drivers/char/nvram.c | |||
@@ -107,6 +107,7 @@ | |||
107 | #include <linux/init.h> | 107 | #include <linux/init.h> |
108 | #include <linux/proc_fs.h> | 108 | #include <linux/proc_fs.h> |
109 | #include <linux/spinlock.h> | 109 | #include <linux/spinlock.h> |
110 | #include <linux/smp_lock.h> | ||
110 | 111 | ||
111 | #include <asm/io.h> | 112 | #include <asm/io.h> |
112 | #include <asm/uaccess.h> | 113 | #include <asm/uaccess.h> |
@@ -333,12 +334,14 @@ nvram_ioctl(struct inode *inode, struct file *file, | |||
333 | static int | 334 | static int |
334 | nvram_open(struct inode *inode, struct file *file) | 335 | nvram_open(struct inode *inode, struct file *file) |
335 | { | 336 | { |
337 | lock_kernel(); | ||
336 | spin_lock(&nvram_state_lock); | 338 | spin_lock(&nvram_state_lock); |
337 | 339 | ||
338 | if ((nvram_open_cnt && (file->f_flags & O_EXCL)) || | 340 | if ((nvram_open_cnt && (file->f_flags & O_EXCL)) || |
339 | (nvram_open_mode & NVRAM_EXCL) || | 341 | (nvram_open_mode & NVRAM_EXCL) || |
340 | ((file->f_mode & 2) && (nvram_open_mode & NVRAM_WRITE))) { | 342 | ((file->f_mode & 2) && (nvram_open_mode & NVRAM_WRITE))) { |
341 | spin_unlock(&nvram_state_lock); | 343 | spin_unlock(&nvram_state_lock); |
344 | unlock_kernel(); | ||
342 | return -EBUSY; | 345 | return -EBUSY; |
343 | } | 346 | } |
344 | 347 | ||
@@ -349,6 +352,7 @@ nvram_open(struct inode *inode, struct file *file) | |||
349 | nvram_open_cnt++; | 352 | nvram_open_cnt++; |
350 | 353 | ||
351 | spin_unlock(&nvram_state_lock); | 354 | spin_unlock(&nvram_state_lock); |
355 | unlock_kernel(); | ||
352 | 356 | ||
353 | return 0; | 357 | return 0; |
354 | } | 358 | } |
diff --git a/drivers/char/pc8736x_gpio.c b/drivers/char/pc8736x_gpio.c index ecfaf180e5bd..b930de50407a 100644 --- a/drivers/char/pc8736x_gpio.c +++ b/drivers/char/pc8736x_gpio.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/mutex.h> | 20 | #include <linux/mutex.h> |
21 | #include <linux/nsc_gpio.h> | 21 | #include <linux/nsc_gpio.h> |
22 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
23 | #include <linux/smp_lock.h> | ||
23 | #include <asm/uaccess.h> | 24 | #include <asm/uaccess.h> |
24 | 25 | ||
25 | #define DEVNAME "pc8736x_gpio" | 26 | #define DEVNAME "pc8736x_gpio" |
@@ -217,6 +218,7 @@ static int pc8736x_gpio_open(struct inode *inode, struct file *file) | |||
217 | unsigned m = iminor(inode); | 218 | unsigned m = iminor(inode); |
218 | file->private_data = &pc8736x_gpio_ops; | 219 | file->private_data = &pc8736x_gpio_ops; |
219 | 220 | ||
221 | cycle_kernel_lock(); | ||
220 | dev_dbg(&pdev->dev, "open %d\n", m); | 222 | dev_dbg(&pdev->dev, "open %d\n", m); |
221 | 223 | ||
222 | if (m >= PC8736X_GPIO_CT) | 224 | if (m >= PC8736X_GPIO_CT) |
diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c index 3aab837d9480..f6e6acadd9a0 100644 --- a/drivers/char/ppdev.c +++ b/drivers/char/ppdev.c | |||
@@ -66,6 +66,7 @@ | |||
66 | #include <linux/poll.h> | 66 | #include <linux/poll.h> |
67 | #include <linux/major.h> | 67 | #include <linux/major.h> |
68 | #include <linux/ppdev.h> | 68 | #include <linux/ppdev.h> |
69 | #include <linux/smp_lock.h> | ||
69 | #include <asm/uaccess.h> | 70 | #include <asm/uaccess.h> |
70 | 71 | ||
71 | #define PP_VERSION "ppdev: user-space parallel port driver" | 72 | #define PP_VERSION "ppdev: user-space parallel port driver" |
@@ -638,6 +639,7 @@ static int pp_open (struct inode * inode, struct file * file) | |||
638 | unsigned int minor = iminor(inode); | 639 | unsigned int minor = iminor(inode); |
639 | struct pp_struct *pp; | 640 | struct pp_struct *pp; |
640 | 641 | ||
642 | cycle_kernel_lock(); | ||
641 | if (minor >= PARPORT_MAX) | 643 | if (minor >= PARPORT_MAX) |
642 | return -ENXIO; | 644 | return -ENXIO; |
643 | 645 | ||
diff --git a/drivers/char/raw.c b/drivers/char/raw.c index bbfa0e241cba..505fcbe884a4 100644 --- a/drivers/char/raw.c +++ b/drivers/char/raw.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/cdev.h> | 19 | #include <linux/cdev.h> |
20 | #include <linux/device.h> | 20 | #include <linux/device.h> |
21 | #include <linux/mutex.h> | 21 | #include <linux/mutex.h> |
22 | #include <linux/smp_lock.h> | ||
22 | 23 | ||
23 | #include <asm/uaccess.h> | 24 | #include <asm/uaccess.h> |
24 | 25 | ||
@@ -53,6 +54,7 @@ static int raw_open(struct inode *inode, struct file *filp) | |||
53 | return 0; | 54 | return 0; |
54 | } | 55 | } |
55 | 56 | ||
57 | lock_kernel(); | ||
56 | mutex_lock(&raw_mutex); | 58 | mutex_lock(&raw_mutex); |
57 | 59 | ||
58 | /* | 60 | /* |
@@ -79,6 +81,7 @@ static int raw_open(struct inode *inode, struct file *filp) | |||
79 | bdev->bd_inode->i_mapping; | 81 | bdev->bd_inode->i_mapping; |
80 | filp->private_data = bdev; | 82 | filp->private_data = bdev; |
81 | mutex_unlock(&raw_mutex); | 83 | mutex_unlock(&raw_mutex); |
84 | unlock_kernel(); | ||
82 | return 0; | 85 | return 0; |
83 | 86 | ||
84 | out2: | 87 | out2: |
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c index 909cac93fa2a..fa92a8af5a5a 100644 --- a/drivers/char/rtc.c +++ b/drivers/char/rtc.c | |||
@@ -73,6 +73,7 @@ | |||
73 | #include <linux/proc_fs.h> | 73 | #include <linux/proc_fs.h> |
74 | #include <linux/seq_file.h> | 74 | #include <linux/seq_file.h> |
75 | #include <linux/spinlock.h> | 75 | #include <linux/spinlock.h> |
76 | #include <linux/smp_lock.h> | ||
76 | #include <linux/sysctl.h> | 77 | #include <linux/sysctl.h> |
77 | #include <linux/wait.h> | 78 | #include <linux/wait.h> |
78 | #include <linux/bcd.h> | 79 | #include <linux/bcd.h> |
@@ -734,6 +735,7 @@ static int rtc_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
734 | * needed here. Or anywhere else in this driver. */ | 735 | * needed here. Or anywhere else in this driver. */ |
735 | static int rtc_open(struct inode *inode, struct file *file) | 736 | static int rtc_open(struct inode *inode, struct file *file) |
736 | { | 737 | { |
738 | lock_kernel(); | ||
737 | spin_lock_irq(&rtc_lock); | 739 | spin_lock_irq(&rtc_lock); |
738 | 740 | ||
739 | if (rtc_status & RTC_IS_OPEN) | 741 | if (rtc_status & RTC_IS_OPEN) |
@@ -743,10 +745,12 @@ static int rtc_open(struct inode *inode, struct file *file) | |||
743 | 745 | ||
744 | rtc_irq_data = 0; | 746 | rtc_irq_data = 0; |
745 | spin_unlock_irq(&rtc_lock); | 747 | spin_unlock_irq(&rtc_lock); |
748 | unlock_kernel(); | ||
746 | return 0; | 749 | return 0; |
747 | 750 | ||
748 | out_busy: | 751 | out_busy: |
749 | spin_unlock_irq(&rtc_lock); | 752 | spin_unlock_irq(&rtc_lock); |
753 | unlock_kernel(); | ||
750 | return -EBUSY; | 754 | return -EBUSY; |
751 | } | 755 | } |
752 | 756 | ||
diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c index 99e5272e3c53..1d9100561c8a 100644 --- a/drivers/char/scx200_gpio.c +++ b/drivers/char/scx200_gpio.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
15 | #include <linux/smp_lock.h> | ||
15 | #include <asm/uaccess.h> | 16 | #include <asm/uaccess.h> |
16 | #include <asm/io.h> | 17 | #include <asm/io.h> |
17 | 18 | ||
@@ -51,6 +52,7 @@ static int scx200_gpio_open(struct inode *inode, struct file *file) | |||
51 | unsigned m = iminor(inode); | 52 | unsigned m = iminor(inode); |
52 | file->private_data = &scx200_gpio_ops; | 53 | file->private_data = &scx200_gpio_ops; |
53 | 54 | ||
55 | cycle_kernel_lock(); | ||
54 | if (m >= MAX_PINS) | 56 | if (m >= MAX_PINS) |
55 | return -EINVAL; | 57 | return -EINVAL; |
56 | return nonseekable_open(inode, file); | 58 | return nonseekable_open(inode, file); |
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c index 8fe099a41065..0b799ac1b049 100644 --- a/drivers/char/snsc.c +++ b/drivers/char/snsc.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/poll.h> | 21 | #include <linux/poll.h> |
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/smp_lock.h> | ||
24 | #include <asm/sn/io.h> | 25 | #include <asm/sn/io.h> |
25 | #include <asm/sn/sn_sal.h> | 26 | #include <asm/sn/sn_sal.h> |
26 | #include <asm/sn/module.h> | 27 | #include <asm/sn/module.h> |
@@ -104,6 +105,7 @@ scdrv_open(struct inode *inode, struct file *file) | |||
104 | file->private_data = sd; | 105 | file->private_data = sd; |
105 | 106 | ||
106 | /* hook this subchannel up to the system controller interrupt */ | 107 | /* hook this subchannel up to the system controller interrupt */ |
108 | lock_kernel(); | ||
107 | rv = request_irq(SGI_UART_VECTOR, scdrv_interrupt, | 109 | rv = request_irq(SGI_UART_VECTOR, scdrv_interrupt, |
108 | IRQF_SHARED | IRQF_DISABLED, | 110 | IRQF_SHARED | IRQF_DISABLED, |
109 | SYSCTL_BASENAME, sd); | 111 | SYSCTL_BASENAME, sd); |
@@ -111,9 +113,10 @@ scdrv_open(struct inode *inode, struct file *file) | |||
111 | ia64_sn_irtr_close(sd->sd_nasid, sd->sd_subch); | 113 | ia64_sn_irtr_close(sd->sd_nasid, sd->sd_subch); |
112 | kfree(sd); | 114 | kfree(sd); |
113 | printk("%s: irq request failed (%d)\n", __func__, rv); | 115 | printk("%s: irq request failed (%d)\n", __func__, rv); |
116 | unlock_kernel(); | ||
114 | return -EBUSY; | 117 | return -EBUSY; |
115 | } | 118 | } |
116 | 119 | unlock_kernel(); | |
117 | return 0; | 120 | return 0; |
118 | } | 121 | } |
119 | 122 | ||
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c index 58533de59027..85e0eb76eeab 100644 --- a/drivers/char/sonypi.c +++ b/drivers/char/sonypi.c | |||
@@ -49,6 +49,7 @@ | |||
49 | #include <linux/err.h> | 49 | #include <linux/err.h> |
50 | #include <linux/kfifo.h> | 50 | #include <linux/kfifo.h> |
51 | #include <linux/platform_device.h> | 51 | #include <linux/platform_device.h> |
52 | #include <linux/smp_lock.h> | ||
52 | 53 | ||
53 | #include <asm/uaccess.h> | 54 | #include <asm/uaccess.h> |
54 | #include <asm/io.h> | 55 | #include <asm/io.h> |
@@ -906,12 +907,14 @@ static int sonypi_misc_release(struct inode *inode, struct file *file) | |||
906 | 907 | ||
907 | static int sonypi_misc_open(struct inode *inode, struct file *file) | 908 | static int sonypi_misc_open(struct inode *inode, struct file *file) |
908 | { | 909 | { |
910 | lock_kernel(); | ||
909 | mutex_lock(&sonypi_device.lock); | 911 | mutex_lock(&sonypi_device.lock); |
910 | /* Flush input queue on first open */ | 912 | /* Flush input queue on first open */ |
911 | if (!sonypi_device.open_count) | 913 | if (!sonypi_device.open_count) |
912 | kfifo_reset(sonypi_device.fifo); | 914 | kfifo_reset(sonypi_device.fifo); |
913 | sonypi_device.open_count++; | 915 | sonypi_device.open_count++; |
914 | mutex_unlock(&sonypi_device.lock); | 916 | mutex_unlock(&sonypi_device.lock); |
917 | unlock_kernel(); | ||
915 | return 0; | 918 | return 0; |
916 | } | 919 | } |
917 | 920 | ||
diff --git a/drivers/char/tb0219.c b/drivers/char/tb0219.c index 4c431cb7cf1b..6062b62800fd 100644 --- a/drivers/char/tb0219.c +++ b/drivers/char/tb0219.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/fs.h> | 21 | #include <linux/fs.h> |
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
24 | #include <linux/smp_lock.h> | ||
24 | 25 | ||
25 | #include <asm/io.h> | 26 | #include <asm/io.h> |
26 | #include <asm/reboot.h> | 27 | #include <asm/reboot.h> |
@@ -236,6 +237,7 @@ static int tanbac_tb0219_open(struct inode *inode, struct file *file) | |||
236 | { | 237 | { |
237 | unsigned int minor; | 238 | unsigned int minor; |
238 | 239 | ||
240 | cycle_kernel_lock(); | ||
239 | minor = iminor(inode); | 241 | minor = iminor(inode); |
240 | switch (minor) { | 242 | switch (minor) { |
241 | case 0: | 243 | case 0: |
diff --git a/drivers/char/tlclk.c b/drivers/char/tlclk.c index 35e58030d296..8f2284be68e1 100644 --- a/drivers/char/tlclk.c +++ b/drivers/char/tlclk.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/ioport.h> | 36 | #include <linux/ioport.h> |
37 | #include <linux/interrupt.h> | 37 | #include <linux/interrupt.h> |
38 | #include <linux/spinlock.h> | 38 | #include <linux/spinlock.h> |
39 | #include <linux/smp_lock.h> | ||
39 | #include <linux/timer.h> | 40 | #include <linux/timer.h> |
40 | #include <linux/sysfs.h> | 41 | #include <linux/sysfs.h> |
41 | #include <linux/device.h> | 42 | #include <linux/device.h> |
@@ -204,11 +205,14 @@ static int tlclk_open(struct inode *inode, struct file *filp) | |||
204 | { | 205 | { |
205 | int result; | 206 | int result; |
206 | 207 | ||
207 | if (test_and_set_bit(0, &useflags)) | 208 | lock_kernel(); |
208 | return -EBUSY; | 209 | if (test_and_set_bit(0, &useflags)) { |
210 | result = -EBUSY; | ||
209 | /* this legacy device is always one per system and it doesn't | 211 | /* this legacy device is always one per system and it doesn't |
210 | * know how to handle multiple concurrent clients. | 212 | * know how to handle multiple concurrent clients. |
211 | */ | 213 | */ |
214 | goto out; | ||
215 | } | ||
212 | 216 | ||
213 | /* Make sure there is no interrupt pending while | 217 | /* Make sure there is no interrupt pending while |
214 | * initialising interrupt handler */ | 218 | * initialising interrupt handler */ |
@@ -218,13 +222,14 @@ static int tlclk_open(struct inode *inode, struct file *filp) | |||
218 | * we can't share this IRQ */ | 222 | * we can't share this IRQ */ |
219 | result = request_irq(telclk_interrupt, &tlclk_interrupt, | 223 | result = request_irq(telclk_interrupt, &tlclk_interrupt, |
220 | IRQF_DISABLED, "telco_clock", tlclk_interrupt); | 224 | IRQF_DISABLED, "telco_clock", tlclk_interrupt); |
221 | if (result == -EBUSY) { | 225 | if (result == -EBUSY) |
222 | printk(KERN_ERR "tlclk: Interrupt can't be reserved.\n"); | 226 | printk(KERN_ERR "tlclk: Interrupt can't be reserved.\n"); |
223 | return -EBUSY; | 227 | else |
224 | } | 228 | inb(TLCLK_REG6); /* Clear interrupt events */ |
225 | inb(TLCLK_REG6); /* Clear interrupt events */ | ||
226 | 229 | ||
227 | return 0; | 230 | out: |
231 | unlock_kernel(); | ||
232 | return result; | ||
228 | } | 233 | } |
229 | 234 | ||
230 | static int tlclk_release(struct inode *inode, struct file *filp) | 235 | static int tlclk_release(struct inode *inode, struct file *filp) |
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c index a5d8bcb40000..e1fc193d9396 100644 --- a/drivers/char/tpm/tpm.c +++ b/drivers/char/tpm/tpm.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/poll.h> | 26 | #include <linux/poll.h> |
27 | #include <linux/mutex.h> | 27 | #include <linux/mutex.h> |
28 | #include <linux/spinlock.h> | 28 | #include <linux/spinlock.h> |
29 | #include <linux/smp_lock.h> | ||
29 | 30 | ||
30 | #include "tpm.h" | 31 | #include "tpm.h" |
31 | 32 | ||
@@ -897,6 +898,7 @@ int tpm_open(struct inode *inode, struct file *file) | |||
897 | int rc = 0, minor = iminor(inode); | 898 | int rc = 0, minor = iminor(inode); |
898 | struct tpm_chip *chip = NULL, *pos; | 899 | struct tpm_chip *chip = NULL, *pos; |
899 | 900 | ||
901 | lock_kernel(); | ||
900 | spin_lock(&driver_lock); | 902 | spin_lock(&driver_lock); |
901 | 903 | ||
902 | list_for_each_entry(pos, &tpm_chip_list, list) { | 904 | list_for_each_entry(pos, &tpm_chip_list, list) { |
@@ -926,16 +928,19 @@ int tpm_open(struct inode *inode, struct file *file) | |||
926 | if (chip->data_buffer == NULL) { | 928 | if (chip->data_buffer == NULL) { |
927 | chip->num_opens--; | 929 | chip->num_opens--; |
928 | put_device(chip->dev); | 930 | put_device(chip->dev); |
931 | unlock_kernel(); | ||
929 | return -ENOMEM; | 932 | return -ENOMEM; |
930 | } | 933 | } |
931 | 934 | ||
932 | atomic_set(&chip->data_pending, 0); | 935 | atomic_set(&chip->data_pending, 0); |
933 | 936 | ||
934 | file->private_data = chip; | 937 | file->private_data = chip; |
938 | unlock_kernel(); | ||
935 | return 0; | 939 | return 0; |
936 | 940 | ||
937 | err_out: | 941 | err_out: |
938 | spin_unlock(&driver_lock); | 942 | spin_unlock(&driver_lock); |
943 | unlock_kernel(); | ||
939 | return rc; | 944 | return rc; |
940 | } | 945 | } |
941 | EXPORT_SYMBOL_GPL(tpm_open); | 946 | EXPORT_SYMBOL_GPL(tpm_open); |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 750131010af0..047a17339f83 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -2665,7 +2665,7 @@ static void release_dev(struct file *filp) | |||
2665 | * ->siglock protects ->signal/->sighand | 2665 | * ->siglock protects ->signal/->sighand |
2666 | */ | 2666 | */ |
2667 | 2667 | ||
2668 | static int tty_open(struct inode *inode, struct file *filp) | 2668 | static int __tty_open(struct inode *inode, struct file *filp) |
2669 | { | 2669 | { |
2670 | struct tty_struct *tty; | 2670 | struct tty_struct *tty; |
2671 | int noctty, retval; | 2671 | int noctty, retval; |
@@ -2779,6 +2779,19 @@ got_driver: | |||
2779 | return 0; | 2779 | return 0; |
2780 | } | 2780 | } |
2781 | 2781 | ||
2782 | /* BKL pushdown: scary code avoidance wrapper */ | ||
2783 | static int tty_open(struct inode *inode, struct file *filp) | ||
2784 | { | ||
2785 | int ret; | ||
2786 | |||
2787 | lock_kernel(); | ||
2788 | ret = __tty_open(inode, filp); | ||
2789 | unlock_kernel(); | ||
2790 | return ret; | ||
2791 | } | ||
2792 | |||
2793 | |||
2794 | |||
2782 | #ifdef CONFIG_UNIX98_PTYS | 2795 | #ifdef CONFIG_UNIX98_PTYS |
2783 | /** | 2796 | /** |
2784 | * ptmx_open - open a unix 98 pty master | 2797 | * ptmx_open - open a unix 98 pty master |
@@ -2792,7 +2805,7 @@ got_driver: | |||
2792 | * allocated_ptys_lock handles the list of free pty numbers | 2805 | * allocated_ptys_lock handles the list of free pty numbers |
2793 | */ | 2806 | */ |
2794 | 2807 | ||
2795 | static int ptmx_open(struct inode *inode, struct file *filp) | 2808 | static int __ptmx_open(struct inode *inode, struct file *filp) |
2796 | { | 2809 | { |
2797 | struct tty_struct *tty; | 2810 | struct tty_struct *tty; |
2798 | int retval; | 2811 | int retval; |
@@ -2831,6 +2844,16 @@ out: | |||
2831 | devpts_kill_index(index); | 2844 | devpts_kill_index(index); |
2832 | return retval; | 2845 | return retval; |
2833 | } | 2846 | } |
2847 | |||
2848 | static int ptmx_open(struct inode *inode, struct file *filp) | ||
2849 | { | ||
2850 | int ret; | ||
2851 | |||
2852 | lock_kernel(); | ||
2853 | ret = __ptmx_open(inode, filp); | ||
2854 | unlock_kernel(); | ||
2855 | return ret; | ||
2856 | } | ||
2834 | #endif | 2857 | #endif |
2835 | 2858 | ||
2836 | /** | 2859 | /** |
@@ -2886,15 +2909,16 @@ static int tty_fasync(int fd, struct file *filp, int on) | |||
2886 | { | 2909 | { |
2887 | struct tty_struct *tty; | 2910 | struct tty_struct *tty; |
2888 | unsigned long flags; | 2911 | unsigned long flags; |
2889 | int retval; | 2912 | int retval = 0; |
2890 | 2913 | ||
2914 | lock_kernel(); | ||
2891 | tty = (struct tty_struct *)filp->private_data; | 2915 | tty = (struct tty_struct *)filp->private_data; |
2892 | if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "tty_fasync")) | 2916 | if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "tty_fasync")) |
2893 | return 0; | 2917 | goto out; |
2894 | 2918 | ||
2895 | retval = fasync_helper(fd, filp, on, &tty->fasync); | 2919 | retval = fasync_helper(fd, filp, on, &tty->fasync); |
2896 | if (retval <= 0) | 2920 | if (retval <= 0) |
2897 | return retval; | 2921 | goto out; |
2898 | 2922 | ||
2899 | if (on) { | 2923 | if (on) { |
2900 | enum pid_type type; | 2924 | enum pid_type type; |
@@ -2912,12 +2936,15 @@ static int tty_fasync(int fd, struct file *filp, int on) | |||
2912 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | 2936 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); |
2913 | retval = __f_setown(filp, pid, type, 0); | 2937 | retval = __f_setown(filp, pid, type, 0); |
2914 | if (retval) | 2938 | if (retval) |
2915 | return retval; | 2939 | goto out; |
2916 | } else { | 2940 | } else { |
2917 | if (!tty->fasync && !waitqueue_active(&tty->read_wait)) | 2941 | if (!tty->fasync && !waitqueue_active(&tty->read_wait)) |
2918 | tty->minimum_to_wake = N_TTY_BUF_SIZE; | 2942 | tty->minimum_to_wake = N_TTY_BUF_SIZE; |
2919 | } | 2943 | } |
2920 | return 0; | 2944 | retval = 0; |
2945 | out: | ||
2946 | unlock_kernel(); | ||
2947 | return retval; | ||
2921 | } | 2948 | } |
2922 | 2949 | ||
2923 | /** | 2950 | /** |
diff --git a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c index 83aeedda200c..eebfad2777d2 100644 --- a/drivers/char/vc_screen.c +++ b/drivers/char/vc_screen.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/kbd_kern.h> | 34 | #include <linux/kbd_kern.h> |
35 | #include <linux/console.h> | 35 | #include <linux/console.h> |
36 | #include <linux/device.h> | 36 | #include <linux/device.h> |
37 | #include <linux/smp_lock.h> | ||
37 | 38 | ||
38 | #include <asm/uaccess.h> | 39 | #include <asm/uaccess.h> |
39 | #include <asm/byteorder.h> | 40 | #include <asm/byteorder.h> |
@@ -460,9 +461,13 @@ static int | |||
460 | vcs_open(struct inode *inode, struct file *filp) | 461 | vcs_open(struct inode *inode, struct file *filp) |
461 | { | 462 | { |
462 | unsigned int currcons = iminor(inode) & 127; | 463 | unsigned int currcons = iminor(inode) & 127; |
464 | int ret = 0; | ||
465 | |||
466 | lock_kernel(); | ||
463 | if(currcons && !vc_cons_allocated(currcons-1)) | 467 | if(currcons && !vc_cons_allocated(currcons-1)) |
464 | return -ENXIO; | 468 | ret = -ENXIO; |
465 | return 0; | 469 | unlock_kernel(); |
470 | return ret; | ||
466 | } | 471 | } |
467 | 472 | ||
468 | static const struct file_operations vcs_fops = { | 473 | static const struct file_operations vcs_fops = { |
diff --git a/drivers/char/viotape.c b/drivers/char/viotape.c index c39ddaff5e8f..977f7d35e769 100644 --- a/drivers/char/viotape.c +++ b/drivers/char/viotape.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/completion.h> | 46 | #include <linux/completion.h> |
47 | #include <linux/proc_fs.h> | 47 | #include <linux/proc_fs.h> |
48 | #include <linux/seq_file.h> | 48 | #include <linux/seq_file.h> |
49 | #include <linux/smp_lock.h> | ||
49 | 50 | ||
50 | #include <asm/uaccess.h> | 51 | #include <asm/uaccess.h> |
51 | #include <asm/ioctls.h> | 52 | #include <asm/ioctls.h> |
@@ -687,6 +688,7 @@ static int viotap_open(struct inode *inode, struct file *file) | |||
687 | if (op == NULL) | 688 | if (op == NULL) |
688 | return -ENOMEM; | 689 | return -ENOMEM; |
689 | 690 | ||
691 | lock_kernel(); | ||
690 | get_dev_info(file->f_path.dentry->d_inode, &devi); | 692 | get_dev_info(file->f_path.dentry->d_inode, &devi); |
691 | 693 | ||
692 | /* Note: We currently only support one mode! */ | 694 | /* Note: We currently only support one mode! */ |
@@ -717,6 +719,7 @@ static int viotap_open(struct inode *inode, struct file *file) | |||
717 | 719 | ||
718 | free_op: | 720 | free_op: |
719 | free_op_struct(op); | 721 | free_op_struct(op); |
722 | unlock_kernel(); | ||
720 | return ret; | 723 | return ret; |
721 | } | 724 | } |
722 | 725 | ||
diff --git a/drivers/char/vr41xx_giu.c b/drivers/char/vr41xx_giu.c index e5ed09192be8..ffe9b4e3072e 100644 --- a/drivers/char/vr41xx_giu.c +++ b/drivers/char/vr41xx_giu.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
28 | #include <linux/module.h> | 28 | #include <linux/module.h> |
29 | #include <linux/platform_device.h> | 29 | #include <linux/platform_device.h> |
30 | #include <linux/smp_lock.h> | ||
30 | #include <linux/spinlock.h> | 31 | #include <linux/spinlock.h> |
31 | #include <linux/types.h> | 32 | #include <linux/types.h> |
32 | 33 | ||
@@ -547,6 +548,7 @@ static int gpio_open(struct inode *inode, struct file *file) | |||
547 | { | 548 | { |
548 | unsigned int pin; | 549 | unsigned int pin; |
549 | 550 | ||
551 | cycle_kernel_lock(); | ||
550 | pin = iminor(inode); | 552 | pin = iminor(inode); |
551 | if (pin >= giu_nr_pins) | 553 | if (pin >= giu_nr_pins) |
552 | return -EBADF; | 554 | return -EBADF; |
diff --git a/drivers/char/xilinx_hwicap/xilinx_hwicap.c b/drivers/char/xilinx_hwicap/xilinx_hwicap.c index 3edf1fc12963..1e1b81e57cdc 100644 --- a/drivers/char/xilinx_hwicap/xilinx_hwicap.c +++ b/drivers/char/xilinx_hwicap/xilinx_hwicap.c | |||
@@ -85,6 +85,7 @@ | |||
85 | #include <linux/poll.h> | 85 | #include <linux/poll.h> |
86 | #include <linux/proc_fs.h> | 86 | #include <linux/proc_fs.h> |
87 | #include <linux/mutex.h> | 87 | #include <linux/mutex.h> |
88 | #include <linux/smp_lock.h> | ||
88 | #include <linux/sysctl.h> | 89 | #include <linux/sysctl.h> |
89 | #include <linux/version.h> | 90 | #include <linux/version.h> |
90 | #include <linux/fs.h> | 91 | #include <linux/fs.h> |
@@ -504,11 +505,12 @@ static int hwicap_open(struct inode *inode, struct file *file) | |||
504 | struct hwicap_drvdata *drvdata; | 505 | struct hwicap_drvdata *drvdata; |
505 | int status; | 506 | int status; |
506 | 507 | ||
508 | lock_kernel(); | ||
507 | drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev); | 509 | drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev); |
508 | 510 | ||
509 | status = mutex_lock_interruptible(&drvdata->sem); | 511 | status = mutex_lock_interruptible(&drvdata->sem); |
510 | if (status) | 512 | if (status) |
511 | return status; | 513 | goto out; |
512 | 514 | ||
513 | if (drvdata->is_open) { | 515 | if (drvdata->is_open) { |
514 | status = -EBUSY; | 516 | status = -EBUSY; |
@@ -528,6 +530,8 @@ static int hwicap_open(struct inode *inode, struct file *file) | |||
528 | 530 | ||
529 | error: | 531 | error: |
530 | mutex_unlock(&drvdata->sem); | 532 | mutex_unlock(&drvdata->sem); |
533 | out: | ||
534 | unlock_kernel(); | ||
531 | return status; | 535 | return status; |
532 | } | 536 | } |
533 | 537 | ||
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index d2e6da85f58a..851a53f1acce 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include "drmP.h" | 37 | #include "drmP.h" |
38 | #include "drm_sarea.h" | 38 | #include "drm_sarea.h" |
39 | #include <linux/poll.h> | 39 | #include <linux/poll.h> |
40 | #include <linux/smp_lock.h> | ||
40 | 41 | ||
41 | static int drm_open_helper(struct inode *inode, struct file *filp, | 42 | static int drm_open_helper(struct inode *inode, struct file *filp, |
42 | struct drm_device * dev); | 43 | struct drm_device * dev); |
@@ -174,12 +175,14 @@ int drm_stub_open(struct inode *inode, struct file *filp) | |||
174 | 175 | ||
175 | DRM_DEBUG("\n"); | 176 | DRM_DEBUG("\n"); |
176 | 177 | ||
178 | /* BKL pushdown: note that nothing else serializes idr_find() */ | ||
179 | lock_kernel(); | ||
177 | minor = idr_find(&drm_minors_idr, minor_id); | 180 | minor = idr_find(&drm_minors_idr, minor_id); |
178 | if (!minor) | 181 | if (!minor) |
179 | return -ENODEV; | 182 | goto out; |
180 | 183 | ||
181 | if (!(dev = minor->dev)) | 184 | if (!(dev = minor->dev)) |
182 | return -ENODEV; | 185 | goto out; |
183 | 186 | ||
184 | old_fops = filp->f_op; | 187 | old_fops = filp->f_op; |
185 | filp->f_op = fops_get(&dev->driver->fops); | 188 | filp->f_op = fops_get(&dev->driver->fops); |
@@ -189,6 +192,8 @@ int drm_stub_open(struct inode *inode, struct file *filp) | |||
189 | } | 192 | } |
190 | fops_put(old_fops); | 193 | fops_put(old_fops); |
191 | 194 | ||
195 | out: | ||
196 | unlock_kernel(); | ||
192 | return err; | 197 | return err; |
193 | } | 198 | } |
194 | 199 | ||
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index 1ca6f4635eeb..2fde6c63f47d 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/major.h> | 30 | #include <linux/major.h> |
31 | #include <linux/hid.h> | 31 | #include <linux/hid.h> |
32 | #include <linux/mutex.h> | 32 | #include <linux/mutex.h> |
33 | #include <linux/smp_lock.h> | ||
33 | 34 | ||
34 | #include <linux/hidraw.h> | 35 | #include <linux/hidraw.h> |
35 | 36 | ||
@@ -157,6 +158,7 @@ static int hidraw_open(struct inode *inode, struct file *file) | |||
157 | struct hidraw_list *list; | 158 | struct hidraw_list *list; |
158 | int err = 0; | 159 | int err = 0; |
159 | 160 | ||
161 | lock_kernel(); | ||
160 | if (!(list = kzalloc(sizeof(struct hidraw_list), GFP_KERNEL))) { | 162 | if (!(list = kzalloc(sizeof(struct hidraw_list), GFP_KERNEL))) { |
161 | err = -ENOMEM; | 163 | err = -ENOMEM; |
162 | goto out; | 164 | goto out; |
@@ -183,6 +185,7 @@ static int hidraw_open(struct inode *inode, struct file *file) | |||
183 | out_unlock: | 185 | out_unlock: |
184 | spin_unlock(&minors_lock); | 186 | spin_unlock(&minors_lock); |
185 | out: | 187 | out: |
188 | unlock_kernel(); | ||
186 | return err; | 189 | return err; |
187 | 190 | ||
188 | } | 191 | } |
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index d34c14c81c29..006a5857256a 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/list.h> | 34 | #include <linux/list.h> |
35 | #include <linux/i2c.h> | 35 | #include <linux/i2c.h> |
36 | #include <linux/i2c-dev.h> | 36 | #include <linux/i2c-dev.h> |
37 | #include <linux/smp_lock.h> | ||
37 | #include <asm/uaccess.h> | 38 | #include <asm/uaccess.h> |
38 | 39 | ||
39 | static struct i2c_driver i2cdev_driver; | 40 | static struct i2c_driver i2cdev_driver; |
@@ -441,14 +442,20 @@ static int i2cdev_open(struct inode *inode, struct file *file) | |||
441 | struct i2c_client *client; | 442 | struct i2c_client *client; |
442 | struct i2c_adapter *adap; | 443 | struct i2c_adapter *adap; |
443 | struct i2c_dev *i2c_dev; | 444 | struct i2c_dev *i2c_dev; |
445 | int ret = 0; | ||
444 | 446 | ||
447 | lock_kernel(); | ||
445 | i2c_dev = i2c_dev_get_by_minor(minor); | 448 | i2c_dev = i2c_dev_get_by_minor(minor); |
446 | if (!i2c_dev) | 449 | if (!i2c_dev) { |
447 | return -ENODEV; | 450 | ret = -ENODEV; |
451 | goto out; | ||
452 | } | ||
448 | 453 | ||
449 | adap = i2c_get_adapter(i2c_dev->adap->nr); | 454 | adap = i2c_get_adapter(i2c_dev->adap->nr); |
450 | if (!adap) | 455 | if (!adap) { |
451 | return -ENODEV; | 456 | ret = -ENODEV; |
457 | goto out; | ||
458 | } | ||
452 | 459 | ||
453 | /* This creates an anonymous i2c_client, which may later be | 460 | /* This creates an anonymous i2c_client, which may later be |
454 | * pointed to some address using I2C_SLAVE or I2C_SLAVE_FORCE. | 461 | * pointed to some address using I2C_SLAVE or I2C_SLAVE_FORCE. |
@@ -460,7 +467,8 @@ static int i2cdev_open(struct inode *inode, struct file *file) | |||
460 | client = kzalloc(sizeof(*client), GFP_KERNEL); | 467 | client = kzalloc(sizeof(*client), GFP_KERNEL); |
461 | if (!client) { | 468 | if (!client) { |
462 | i2c_put_adapter(adap); | 469 | i2c_put_adapter(adap); |
463 | return -ENOMEM; | 470 | ret = -ENOMEM; |
471 | goto out; | ||
464 | } | 472 | } |
465 | snprintf(client->name, I2C_NAME_SIZE, "i2c-dev %d", adap->nr); | 473 | snprintf(client->name, I2C_NAME_SIZE, "i2c-dev %d", adap->nr); |
466 | client->driver = &i2cdev_driver; | 474 | client->driver = &i2cdev_driver; |
@@ -468,7 +476,9 @@ static int i2cdev_open(struct inode *inode, struct file *file) | |||
468 | client->adapter = adap; | 476 | client->adapter = adap; |
469 | file->private_data = client; | 477 | file->private_data = client; |
470 | 478 | ||
471 | return 0; | 479 | out: |
480 | unlock_kernel(); | ||
481 | return ret; | ||
472 | } | 482 | } |
473 | 483 | ||
474 | static int i2cdev_release(struct inode *inode, struct file *file) | 484 | static int i2cdev_release(struct inode *inode, struct file *file) |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 1e1f26331a24..a3d228302d20 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -2421,9 +2421,12 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
2421 | if (i >= MAX_HWIFS * MAX_DRIVES) | 2421 | if (i >= MAX_HWIFS * MAX_DRIVES) |
2422 | return -ENXIO; | 2422 | return -ENXIO; |
2423 | 2423 | ||
2424 | lock_kernel(); | ||
2424 | tape = ide_tape_chrdev_get(i); | 2425 | tape = ide_tape_chrdev_get(i); |
2425 | if (!tape) | 2426 | if (!tape) { |
2427 | unlock_kernel(); | ||
2426 | return -ENXIO; | 2428 | return -ENXIO; |
2429 | } | ||
2427 | 2430 | ||
2428 | debug_log(DBG_CHRDEV, "Enter %s\n", __func__); | 2431 | debug_log(DBG_CHRDEV, "Enter %s\n", __func__); |
2429 | 2432 | ||
@@ -2482,10 +2485,12 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
2482 | } | 2485 | } |
2483 | } | 2486 | } |
2484 | } | 2487 | } |
2488 | unlock_kernel(); | ||
2485 | return 0; | 2489 | return 0; |
2486 | 2490 | ||
2487 | out_put_tape: | 2491 | out_put_tape: |
2488 | ide_tape_put(tape); | 2492 | ide_tape_put(tape); |
2493 | unlock_kernel(); | ||
2489 | return retval; | 2494 | return retval; |
2490 | } | 2495 | } |
2491 | 2496 | ||
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c index d7a6881b571d..b25675faaaf5 100644 --- a/drivers/infiniband/core/ucm.c +++ b/drivers/infiniband/core/ucm.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include <linux/cdev.h> | 45 | #include <linux/cdev.h> |
46 | #include <linux/idr.h> | 46 | #include <linux/idr.h> |
47 | #include <linux/mutex.h> | 47 | #include <linux/mutex.h> |
48 | #include <linux/smp_lock.h> | ||
48 | 49 | ||
49 | #include <asm/uaccess.h> | 50 | #include <asm/uaccess.h> |
50 | 51 | ||
@@ -1159,6 +1160,7 @@ static int ib_ucm_open(struct inode *inode, struct file *filp) | |||
1159 | { | 1160 | { |
1160 | struct ib_ucm_file *file; | 1161 | struct ib_ucm_file *file; |
1161 | 1162 | ||
1163 | cycle_kernel_lock(); | ||
1162 | file = kmalloc(sizeof(*file), GFP_KERNEL); | 1164 | file = kmalloc(sizeof(*file), GFP_KERNEL); |
1163 | if (!file) | 1165 | if (!file) |
1164 | return -ENOMEM; | 1166 | return -ENOMEM; |
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c index ca4cf3a511ab..195f97302fe5 100644 --- a/drivers/infiniband/core/ucma.c +++ b/drivers/infiniband/core/ucma.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/in.h> | 38 | #include <linux/in.h> |
39 | #include <linux/in6.h> | 39 | #include <linux/in6.h> |
40 | #include <linux/miscdevice.h> | 40 | #include <linux/miscdevice.h> |
41 | #include <linux/smp_lock.h> | ||
41 | 42 | ||
42 | #include <rdma/rdma_user_cm.h> | 43 | #include <rdma/rdma_user_cm.h> |
43 | #include <rdma/ib_marshall.h> | 44 | #include <rdma/ib_marshall.h> |
@@ -1156,6 +1157,7 @@ static int ucma_open(struct inode *inode, struct file *filp) | |||
1156 | if (!file) | 1157 | if (!file) |
1157 | return -ENOMEM; | 1158 | return -ENOMEM; |
1158 | 1159 | ||
1160 | lock_kernel(); | ||
1159 | INIT_LIST_HEAD(&file->event_list); | 1161 | INIT_LIST_HEAD(&file->event_list); |
1160 | INIT_LIST_HEAD(&file->ctx_list); | 1162 | INIT_LIST_HEAD(&file->ctx_list); |
1161 | init_waitqueue_head(&file->poll_wait); | 1163 | init_waitqueue_head(&file->poll_wait); |
@@ -1163,6 +1165,7 @@ static int ucma_open(struct inode *inode, struct file *filp) | |||
1163 | 1165 | ||
1164 | filp->private_data = file; | 1166 | filp->private_data = file; |
1165 | file->filp = filp; | 1167 | file->filp = filp; |
1168 | unlock_kernel(); | ||
1166 | return 0; | 1169 | return 0; |
1167 | } | 1170 | } |
1168 | 1171 | ||
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c index 840ede9ae965..208c7f34323c 100644 --- a/drivers/infiniband/core/user_mad.c +++ b/drivers/infiniband/core/user_mad.c | |||
@@ -777,6 +777,19 @@ static long ib_umad_compat_ioctl(struct file *filp, unsigned int cmd, | |||
777 | } | 777 | } |
778 | #endif | 778 | #endif |
779 | 779 | ||
780 | /* | ||
781 | * ib_umad_open() does not need the BKL: | ||
782 | * | ||
783 | * - umad_port[] accesses are protected by port_lock, the | ||
784 | * ib_umad_port structures are properly reference counted, and | ||
785 | * everything else is purely local to the file being created, so | ||
786 | * races against other open calls are not a problem; | ||
787 | * - the ioctl method does not affect any global state outside of the | ||
788 | * file structure being operated on; | ||
789 | * - the port is added to umad_port[] as the last part of module | ||
790 | * initialization so the open method will either immediately run | ||
791 | * -ENXIO, or all required initialization will be done. | ||
792 | */ | ||
780 | static int ib_umad_open(struct inode *inode, struct file *filp) | 793 | static int ib_umad_open(struct inode *inode, struct file *filp) |
781 | { | 794 | { |
782 | struct ib_umad_port *port; | 795 | struct ib_umad_port *port; |
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index caed42bf7ef5..0f34858e31e7 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c | |||
@@ -610,6 +610,18 @@ static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma) | |||
610 | return file->device->ib_dev->mmap(file->ucontext, vma); | 610 | return file->device->ib_dev->mmap(file->ucontext, vma); |
611 | } | 611 | } |
612 | 612 | ||
613 | /* | ||
614 | * ib_uverbs_open() does not need the BKL: | ||
615 | * | ||
616 | * - dev_table[] accesses are protected by map_lock, the | ||
617 | * ib_uverbs_device structures are properly reference counted, and | ||
618 | * everything else is purely local to the file being created, so | ||
619 | * races against other open calls are not a problem; | ||
620 | * - there is no ioctl method to race against; | ||
621 | * - the device is added to dev_table[] as the last part of module | ||
622 | * initialization, the open method will either immediately run | ||
623 | * -ENXIO, or all required initialization will be done. | ||
624 | */ | ||
613 | static int ib_uverbs_open(struct inode *inode, struct file *filp) | 625 | static int ib_uverbs_open(struct inode *inode, struct file *filp) |
614 | { | 626 | { |
615 | struct ib_uverbs_device *dev; | 627 | struct ib_uverbs_device *dev; |
@@ -651,7 +663,6 @@ err_module: | |||
651 | 663 | ||
652 | err: | 664 | err: |
653 | kref_put(&dev->ref, ib_uverbs_release_dev); | 665 | kref_put(&dev->ref, ib_uverbs_release_dev); |
654 | |||
655 | return ret; | 666 | return ret; |
656 | } | 667 | } |
657 | 668 | ||
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c index b472b15637f0..35f301c88b57 100644 --- a/drivers/infiniband/hw/ipath/ipath_file_ops.c +++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/highmem.h> | 39 | #include <linux/highmem.h> |
40 | #include <linux/io.h> | 40 | #include <linux/io.h> |
41 | #include <linux/jiffies.h> | 41 | #include <linux/jiffies.h> |
42 | #include <linux/smp_lock.h> | ||
42 | #include <asm/pgtable.h> | 43 | #include <asm/pgtable.h> |
43 | 44 | ||
44 | #include "ipath_kernel.h" | 45 | #include "ipath_kernel.h" |
@@ -1815,6 +1816,7 @@ done: | |||
1815 | static int ipath_open(struct inode *in, struct file *fp) | 1816 | static int ipath_open(struct inode *in, struct file *fp) |
1816 | { | 1817 | { |
1817 | /* The real work is performed later in ipath_assign_port() */ | 1818 | /* The real work is performed later in ipath_assign_port() */ |
1819 | cycle_kernel_lock(); | ||
1818 | fp->private_data = kzalloc(sizeof(struct ipath_filedata), GFP_KERNEL); | 1820 | fp->private_data = kzalloc(sizeof(struct ipath_filedata), GFP_KERNEL); |
1819 | return fp->private_data ? 0 : -ENOMEM; | 1821 | return fp->private_data ? 0 : -ENOMEM; |
1820 | } | 1822 | } |
diff --git a/drivers/input/input.c b/drivers/input/input.c index 27006fc18305..408df0bd6be5 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/device.h> | 21 | #include <linux/device.h> |
22 | #include <linux/mutex.h> | 22 | #include <linux/mutex.h> |
23 | #include <linux/rcupdate.h> | 23 | #include <linux/rcupdate.h> |
24 | #include <linux/smp_lock.h> | ||
24 | 25 | ||
25 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); | 26 | MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); |
26 | MODULE_DESCRIPTION("Input core"); | 27 | MODULE_DESCRIPTION("Input core"); |
@@ -1588,13 +1589,17 @@ EXPORT_SYMBOL(input_unregister_handle); | |||
1588 | 1589 | ||
1589 | static int input_open_file(struct inode *inode, struct file *file) | 1590 | static int input_open_file(struct inode *inode, struct file *file) |
1590 | { | 1591 | { |
1591 | struct input_handler *handler = input_table[iminor(inode) >> 5]; | 1592 | struct input_handler *handler; |
1592 | const struct file_operations *old_fops, *new_fops = NULL; | 1593 | const struct file_operations *old_fops, *new_fops = NULL; |
1593 | int err; | 1594 | int err; |
1594 | 1595 | ||
1596 | lock_kernel(); | ||
1595 | /* No load-on-demand here? */ | 1597 | /* No load-on-demand here? */ |
1596 | if (!handler || !(new_fops = fops_get(handler->fops))) | 1598 | handler = input_table[iminor(inode) >> 5]; |
1597 | return -ENODEV; | 1599 | if (!handler || !(new_fops = fops_get(handler->fops))) { |
1600 | err = -ENODEV; | ||
1601 | goto out; | ||
1602 | } | ||
1598 | 1603 | ||
1599 | /* | 1604 | /* |
1600 | * That's _really_ odd. Usually NULL ->open means "nothing special", | 1605 | * That's _really_ odd. Usually NULL ->open means "nothing special", |
@@ -1602,7 +1607,8 @@ static int input_open_file(struct inode *inode, struct file *file) | |||
1602 | */ | 1607 | */ |
1603 | if (!new_fops->open) { | 1608 | if (!new_fops->open) { |
1604 | fops_put(new_fops); | 1609 | fops_put(new_fops); |
1605 | return -ENODEV; | 1610 | err = -ENODEV; |
1611 | goto out; | ||
1606 | } | 1612 | } |
1607 | old_fops = file->f_op; | 1613 | old_fops = file->f_op; |
1608 | file->f_op = new_fops; | 1614 | file->f_op = new_fops; |
@@ -1614,6 +1620,8 @@ static int input_open_file(struct inode *inode, struct file *file) | |||
1614 | file->f_op = fops_get(old_fops); | 1620 | file->f_op = fops_get(old_fops); |
1615 | } | 1621 | } |
1616 | fops_put(old_fops); | 1622 | fops_put(old_fops); |
1623 | out: | ||
1624 | unlock_kernel(); | ||
1617 | return err; | 1625 | return err; |
1618 | } | 1626 | } |
1619 | 1627 | ||
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c index 45e5d05b01de..49d8abfe38fe 100644 --- a/drivers/input/misc/hp_sdc_rtc.c +++ b/drivers/input/misc/hp_sdc_rtc.c | |||
@@ -35,6 +35,7 @@ | |||
35 | 35 | ||
36 | #include <linux/hp_sdc.h> | 36 | #include <linux/hp_sdc.h> |
37 | #include <linux/errno.h> | 37 | #include <linux/errno.h> |
38 | #include <linux/smp_lock.h> | ||
38 | #include <linux/types.h> | 39 | #include <linux/types.h> |
39 | #include <linux/init.h> | 40 | #include <linux/init.h> |
40 | #include <linux/module.h> | 41 | #include <linux/module.h> |
@@ -408,6 +409,7 @@ static unsigned int hp_sdc_rtc_poll(struct file *file, poll_table *wait) | |||
408 | 409 | ||
409 | static int hp_sdc_rtc_open(struct inode *inode, struct file *file) | 410 | static int hp_sdc_rtc_open(struct inode *inode, struct file *file) |
410 | { | 411 | { |
412 | cycle_kernel_lock(); | ||
411 | return 0; | 413 | return 0; |
412 | } | 414 | } |
413 | 415 | ||
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index a56ad4ba8fe2..2bcfa0b35061 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/fs.h> | 37 | #include <linux/fs.h> |
38 | #include <linux/miscdevice.h> | 38 | #include <linux/miscdevice.h> |
39 | #include <linux/uinput.h> | 39 | #include <linux/uinput.h> |
40 | #include <linux/smp_lock.h> | ||
40 | 41 | ||
41 | static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) | 42 | static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) |
42 | { | 43 | { |
@@ -222,6 +223,7 @@ static int uinput_open(struct inode *inode, struct file *file) | |||
222 | if (!newdev) | 223 | if (!newdev) |
223 | return -ENOMEM; | 224 | return -ENOMEM; |
224 | 225 | ||
226 | lock_kernel(); | ||
225 | mutex_init(&newdev->mutex); | 227 | mutex_init(&newdev->mutex); |
226 | spin_lock_init(&newdev->requests_lock); | 228 | spin_lock_init(&newdev->requests_lock); |
227 | init_waitqueue_head(&newdev->requests_waitq); | 229 | init_waitqueue_head(&newdev->requests_waitq); |
@@ -229,6 +231,7 @@ static int uinput_open(struct inode *inode, struct file *file) | |||
229 | newdev->state = UIST_NEW_DEVICE; | 231 | newdev->state = UIST_NEW_DEVICE; |
230 | 232 | ||
231 | file->private_data = newdev; | 233 | file->private_data = newdev; |
234 | unlock_kernel(); | ||
232 | 235 | ||
233 | return 0; | 236 | return 0; |
234 | } | 237 | } |
diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c index b989748598ae..8137e50ded87 100644 --- a/drivers/input/mousedev.c +++ b/drivers/input/mousedev.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #define MOUSEDEV_MIX 31 | 14 | #define MOUSEDEV_MIX 31 |
15 | 15 | ||
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/smp_lock.h> | ||
17 | #include <linux/poll.h> | 18 | #include <linux/poll.h> |
18 | #include <linux/module.h> | 19 | #include <linux/module.h> |
19 | #include <linux/init.h> | 20 | #include <linux/init.h> |
@@ -545,16 +546,21 @@ static int mousedev_open(struct inode *inode, struct file *file) | |||
545 | if (i >= MOUSEDEV_MINORS) | 546 | if (i >= MOUSEDEV_MINORS) |
546 | return -ENODEV; | 547 | return -ENODEV; |
547 | 548 | ||
549 | lock_kernel(); | ||
548 | error = mutex_lock_interruptible(&mousedev_table_mutex); | 550 | error = mutex_lock_interruptible(&mousedev_table_mutex); |
549 | if (error) | 551 | if (error) { |
552 | unlock_kernel(); | ||
550 | return error; | 553 | return error; |
554 | } | ||
551 | mousedev = mousedev_table[i]; | 555 | mousedev = mousedev_table[i]; |
552 | if (mousedev) | 556 | if (mousedev) |
553 | get_device(&mousedev->dev); | 557 | get_device(&mousedev->dev); |
554 | mutex_unlock(&mousedev_table_mutex); | 558 | mutex_unlock(&mousedev_table_mutex); |
555 | 559 | ||
556 | if (!mousedev) | 560 | if (!mousedev) { |
561 | unlock_kernel(); | ||
557 | return -ENODEV; | 562 | return -ENODEV; |
563 | } | ||
558 | 564 | ||
559 | client = kzalloc(sizeof(struct mousedev_client), GFP_KERNEL); | 565 | client = kzalloc(sizeof(struct mousedev_client), GFP_KERNEL); |
560 | if (!client) { | 566 | if (!client) { |
@@ -573,6 +579,7 @@ static int mousedev_open(struct inode *inode, struct file *file) | |||
573 | goto err_free_client; | 579 | goto err_free_client; |
574 | 580 | ||
575 | file->private_data = client; | 581 | file->private_data = client; |
582 | unlock_kernel(); | ||
576 | return 0; | 583 | return 0; |
577 | 584 | ||
578 | err_free_client: | 585 | err_free_client: |
@@ -580,6 +587,7 @@ static int mousedev_open(struct inode *inode, struct file *file) | |||
580 | kfree(client); | 587 | kfree(client); |
581 | err_put_mousedev: | 588 | err_put_mousedev: |
582 | put_device(&mousedev->dev); | 589 | put_device(&mousedev->dev); |
590 | unlock_kernel(); | ||
583 | return error; | 591 | return error; |
584 | } | 592 | } |
585 | 593 | ||
diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c index 0403622ae267..c9397c8ee97e 100644 --- a/drivers/input/serio/serio_raw.c +++ b/drivers/input/serio/serio_raw.c | |||
@@ -10,6 +10,7 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | #include <linux/smp_lock.h> | ||
13 | #include <linux/poll.h> | 14 | #include <linux/poll.h> |
14 | #include <linux/module.h> | 15 | #include <linux/module.h> |
15 | #include <linux/serio.h> | 16 | #include <linux/serio.h> |
@@ -81,9 +82,10 @@ static int serio_raw_open(struct inode *inode, struct file *file) | |||
81 | struct serio_raw_list *list; | 82 | struct serio_raw_list *list; |
82 | int retval = 0; | 83 | int retval = 0; |
83 | 84 | ||
85 | lock_kernel(); | ||
84 | retval = mutex_lock_interruptible(&serio_raw_mutex); | 86 | retval = mutex_lock_interruptible(&serio_raw_mutex); |
85 | if (retval) | 87 | if (retval) |
86 | return retval; | 88 | goto out_bkl; |
87 | 89 | ||
88 | if (!(serio_raw = serio_raw_locate(iminor(inode)))) { | 90 | if (!(serio_raw = serio_raw_locate(iminor(inode)))) { |
89 | retval = -ENODEV; | 91 | retval = -ENODEV; |
@@ -108,6 +110,8 @@ static int serio_raw_open(struct inode *inode, struct file *file) | |||
108 | 110 | ||
109 | out: | 111 | out: |
110 | mutex_unlock(&serio_raw_mutex); | 112 | mutex_unlock(&serio_raw_mutex); |
113 | out_bkl: | ||
114 | unlock_kernel(); | ||
111 | return retval; | 115 | return retval; |
112 | } | 116 | } |
113 | 117 | ||
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index 6ca0bb949ad3..2095153582f1 100644 --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/signal.h> | 20 | #include <linux/signal.h> |
21 | #include <linux/mutex.h> | 21 | #include <linux/mutex.h> |
22 | #include <linux/mm.h> | 22 | #include <linux/mm.h> |
23 | #include <linux/smp_lock.h> | ||
23 | #include <linux/timer.h> | 24 | #include <linux/timer.h> |
24 | #include <linux/wait.h> | 25 | #include <linux/wait.h> |
25 | #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE | 26 | #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE |
@@ -983,13 +984,17 @@ capi_ioctl(struct inode *inode, struct file *file, | |||
983 | static int | 984 | static int |
984 | capi_open(struct inode *inode, struct file *file) | 985 | capi_open(struct inode *inode, struct file *file) |
985 | { | 986 | { |
987 | int ret; | ||
988 | |||
989 | lock_kernel(); | ||
986 | if (file->private_data) | 990 | if (file->private_data) |
987 | return -EEXIST; | 991 | ret = -EEXIST; |
988 | 992 | else if ((file->private_data = capidev_alloc()) == NULL) | |
989 | if ((file->private_data = capidev_alloc()) == NULL) | 993 | ret = -ENOMEM; |
990 | return -ENOMEM; | 994 | else |
991 | 995 | ret = nonseekable_open(inode, file); | |
992 | return nonseekable_open(inode, file); | 996 | unlock_kernel(); |
997 | return ret; | ||
993 | } | 998 | } |
994 | 999 | ||
995 | static int | 1000 | static int |
diff --git a/drivers/isdn/hardware/eicon/divamnt.c b/drivers/isdn/hardware/eicon/divamnt.c index c90928974249..1e85f743214e 100644 --- a/drivers/isdn/hardware/eicon/divamnt.c +++ b/drivers/isdn/hardware/eicon/divamnt.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
16 | #include <linux/poll.h> | 16 | #include <linux/poll.h> |
17 | #include <linux/smp_lock.h> | ||
17 | #include <asm/uaccess.h> | 18 | #include <asm/uaccess.h> |
18 | 19 | ||
19 | #include "platform.h" | 20 | #include "platform.h" |
@@ -127,14 +128,19 @@ static unsigned int maint_poll(struct file *file, poll_table * wait) | |||
127 | 128 | ||
128 | static int maint_open(struct inode *ino, struct file *filep) | 129 | static int maint_open(struct inode *ino, struct file *filep) |
129 | { | 130 | { |
131 | int ret; | ||
132 | |||
133 | lock_kernel(); | ||
130 | /* only one open is allowed, so we test | 134 | /* only one open is allowed, so we test |
131 | it atomically */ | 135 | it atomically */ |
132 | if (test_and_set_bit(0, &opened)) | 136 | if (test_and_set_bit(0, &opened)) |
133 | return (-EBUSY); | 137 | ret = -EBUSY; |
134 | 138 | else { | |
135 | filep->private_data = NULL; | 139 | filep->private_data = NULL; |
136 | 140 | ret = nonseekable_open(ino, filep); | |
137 | return nonseekable_open(ino, filep); | 141 | } |
142 | unlock_kernel(); | ||
143 | return ret; | ||
138 | } | 144 | } |
139 | 145 | ||
140 | static int maint_close(struct inode *ino, struct file *filep) | 146 | static int maint_close(struct inode *ino, struct file *filep) |
diff --git a/drivers/isdn/hardware/eicon/divasi.c b/drivers/isdn/hardware/eicon/divasi.c index 78f141e77466..f4969fe0a055 100644 --- a/drivers/isdn/hardware/eicon/divasi.c +++ b/drivers/isdn/hardware/eicon/divasi.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/poll.h> | 17 | #include <linux/poll.h> |
18 | #include <linux/proc_fs.h> | 18 | #include <linux/proc_fs.h> |
19 | #include <linux/skbuff.h> | 19 | #include <linux/skbuff.h> |
20 | #include <linux/smp_lock.h> | ||
20 | #include <asm/uaccess.h> | 21 | #include <asm/uaccess.h> |
21 | 22 | ||
22 | #include "platform.h" | 23 | #include "platform.h" |
@@ -400,6 +401,7 @@ static unsigned int um_idi_poll(struct file *file, poll_table * wait) | |||
400 | 401 | ||
401 | static int um_idi_open(struct inode *inode, struct file *file) | 402 | static int um_idi_open(struct inode *inode, struct file *file) |
402 | { | 403 | { |
404 | cycle_kernel_lock(); | ||
403 | return (0); | 405 | return (0); |
404 | } | 406 | } |
405 | 407 | ||
diff --git a/drivers/isdn/hardware/eicon/divasmain.c b/drivers/isdn/hardware/eicon/divasmain.c index 16a874bb1561..fbbcb27fb681 100644 --- a/drivers/isdn/hardware/eicon/divasmain.c +++ b/drivers/isdn/hardware/eicon/divasmain.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/list.h> | 21 | #include <linux/list.h> |
22 | #include <linux/poll.h> | 22 | #include <linux/poll.h> |
23 | #include <linux/kmod.h> | 23 | #include <linux/kmod.h> |
24 | #include <linux/smp_lock.h> | ||
24 | 25 | ||
25 | #include "platform.h" | 26 | #include "platform.h" |
26 | #undef ID_MASK | 27 | #undef ID_MASK |
@@ -580,6 +581,7 @@ xdi_copy_from_user(void *os_handle, void *dst, const void __user *src, int lengt | |||
580 | */ | 581 | */ |
581 | static int divas_open(struct inode *inode, struct file *file) | 582 | static int divas_open(struct inode *inode, struct file *file) |
582 | { | 583 | { |
584 | cycle_kernel_lock(); | ||
583 | return (0); | 585 | return (0); |
584 | } | 586 | } |
585 | 587 | ||
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 8d8c6b736167..7188c59a76ff 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c | |||
@@ -1732,7 +1732,7 @@ isdn_open(struct inode *ino, struct file *filep) | |||
1732 | int chidx; | 1732 | int chidx; |
1733 | int retval = -ENODEV; | 1733 | int retval = -ENODEV; |
1734 | 1734 | ||
1735 | 1735 | lock_kernel(); | |
1736 | if (minor == ISDN_MINOR_STATUS) { | 1736 | if (minor == ISDN_MINOR_STATUS) { |
1737 | infostruct *p; | 1737 | infostruct *p; |
1738 | 1738 | ||
@@ -1783,6 +1783,7 @@ isdn_open(struct inode *ino, struct file *filep) | |||
1783 | #endif | 1783 | #endif |
1784 | out: | 1784 | out: |
1785 | nonseekable_open(ino, filep); | 1785 | nonseekable_open(ino, filep); |
1786 | unlock_kernel(); | ||
1786 | return retval; | 1787 | return retval; |
1787 | } | 1788 | } |
1788 | 1789 | ||
diff --git a/drivers/macintosh/adb.c b/drivers/macintosh/adb.c index dbaad39020a1..40c70ba62bf0 100644 --- a/drivers/macintosh/adb.c +++ b/drivers/macintosh/adb.c | |||
@@ -644,12 +644,18 @@ do_adb_query(struct adb_request *req) | |||
644 | static int adb_open(struct inode *inode, struct file *file) | 644 | static int adb_open(struct inode *inode, struct file *file) |
645 | { | 645 | { |
646 | struct adbdev_state *state; | 646 | struct adbdev_state *state; |
647 | int ret = 0; | ||
647 | 648 | ||
648 | if (iminor(inode) > 0 || adb_controller == NULL) | 649 | lock_kernel(); |
649 | return -ENXIO; | 650 | if (iminor(inode) > 0 || adb_controller == NULL) { |
651 | ret = -ENXIO; | ||
652 | goto out; | ||
653 | } | ||
650 | state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL); | 654 | state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL); |
651 | if (state == 0) | 655 | if (state == 0) { |
652 | return -ENOMEM; | 656 | ret = -ENOMEM; |
657 | goto out; | ||
658 | } | ||
653 | file->private_data = state; | 659 | file->private_data = state; |
654 | spin_lock_init(&state->lock); | 660 | spin_lock_init(&state->lock); |
655 | atomic_set(&state->n_pending, 0); | 661 | atomic_set(&state->n_pending, 0); |
@@ -657,7 +663,9 @@ static int adb_open(struct inode *inode, struct file *file) | |||
657 | init_waitqueue_head(&state->wait_queue); | 663 | init_waitqueue_head(&state->wait_queue); |
658 | state->inuse = 1; | 664 | state->inuse = 1; |
659 | 665 | ||
660 | return 0; | 666 | out: |
667 | unlock_kernel(); | ||
668 | return ret; | ||
661 | } | 669 | } |
662 | 670 | ||
663 | static int adb_release(struct inode *inode, struct file *file) | 671 | static int adb_release(struct inode *inode, struct file *file) |
diff --git a/drivers/macintosh/ans-lcd.c b/drivers/macintosh/ans-lcd.c index 73c50bc02095..6a8221893256 100644 --- a/drivers/macintosh/ans-lcd.c +++ b/drivers/macintosh/ans-lcd.c | |||
@@ -3,6 +3,7 @@ | |||
3 | */ | 3 | */ |
4 | 4 | ||
5 | #include <linux/types.h> | 5 | #include <linux/types.h> |
6 | #include <linux/smp_lock.h> | ||
6 | #include <linux/errno.h> | 7 | #include <linux/errno.h> |
7 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
8 | #include <linux/miscdevice.h> | 9 | #include <linux/miscdevice.h> |
@@ -119,6 +120,7 @@ anslcd_ioctl( struct inode * inode, struct file * file, | |||
119 | static int | 120 | static int |
120 | anslcd_open( struct inode * inode, struct file * file ) | 121 | anslcd_open( struct inode * inode, struct file * file ) |
121 | { | 122 | { |
123 | cycle_kernel_lock(); | ||
122 | return 0; | 124 | return 0; |
123 | } | 125 | } |
124 | 126 | ||
diff --git a/drivers/macintosh/smu.c b/drivers/macintosh/smu.c index d86d57af282a..32cb0298f88e 100644 --- a/drivers/macintosh/smu.c +++ b/drivers/macintosh/smu.c | |||
@@ -19,6 +19,7 @@ | |||
19 | * the userland interface | 19 | * the userland interface |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <linux/smp_lock.h> | ||
22 | #include <linux/types.h> | 23 | #include <linux/types.h> |
23 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
24 | #include <linux/device.h> | 25 | #include <linux/device.h> |
@@ -1086,10 +1087,12 @@ static int smu_open(struct inode *inode, struct file *file) | |||
1086 | pp->mode = smu_file_commands; | 1087 | pp->mode = smu_file_commands; |
1087 | init_waitqueue_head(&pp->wait); | 1088 | init_waitqueue_head(&pp->wait); |
1088 | 1089 | ||
1090 | lock_kernel(); | ||
1089 | spin_lock_irqsave(&smu_clist_lock, flags); | 1091 | spin_lock_irqsave(&smu_clist_lock, flags); |
1090 | list_add(&pp->list, &smu_clist); | 1092 | list_add(&pp->list, &smu_clist); |
1091 | spin_unlock_irqrestore(&smu_clist_lock, flags); | 1093 | spin_unlock_irqrestore(&smu_clist_lock, flags); |
1092 | file->private_data = pp; | 1094 | file->private_data = pp; |
1095 | unlock_kernel(); | ||
1093 | 1096 | ||
1094 | return 0; | 1097 | return 0; |
1095 | } | 1098 | } |
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index d6365a9f0637..d524dc245a2c 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c | |||
@@ -18,6 +18,7 @@ | |||
18 | * | 18 | * |
19 | */ | 19 | */ |
20 | #include <stdarg.h> | 20 | #include <stdarg.h> |
21 | #include <linux/smp_lock.h> | ||
21 | #include <linux/types.h> | 22 | #include <linux/types.h> |
22 | #include <linux/errno.h> | 23 | #include <linux/errno.h> |
23 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
@@ -2047,6 +2048,7 @@ pmu_open(struct inode *inode, struct file *file) | |||
2047 | pp->rb_get = pp->rb_put = 0; | 2048 | pp->rb_get = pp->rb_put = 0; |
2048 | spin_lock_init(&pp->lock); | 2049 | spin_lock_init(&pp->lock); |
2049 | init_waitqueue_head(&pp->wait); | 2050 | init_waitqueue_head(&pp->wait); |
2051 | lock_kernel(); | ||
2050 | spin_lock_irqsave(&all_pvt_lock, flags); | 2052 | spin_lock_irqsave(&all_pvt_lock, flags); |
2051 | #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) | 2053 | #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) |
2052 | pp->backlight_locker = 0; | 2054 | pp->backlight_locker = 0; |
@@ -2054,6 +2056,7 @@ pmu_open(struct inode *inode, struct file *file) | |||
2054 | list_add(&pp->list, &all_pmu_pvt); | 2056 | list_add(&pp->list, &all_pmu_pvt); |
2055 | spin_unlock_irqrestore(&all_pvt_lock, flags); | 2057 | spin_unlock_irqrestore(&all_pvt_lock, flags); |
2056 | file->private_data = pp; | 2058 | file->private_data = pp; |
2059 | unlock_kernel(); | ||
2057 | return 0; | 2060 | return 0; |
2058 | } | 2061 | } |
2059 | 2062 | ||
diff --git a/drivers/media/dvb/dvb-core/dvbdev.c b/drivers/media/dvb/dvb-core/dvbdev.c index 8b56d929f7fd..e208a60c048a 100644 --- a/drivers/media/dvb/dvb-core/dvbdev.c +++ b/drivers/media/dvb/dvb-core/dvbdev.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/fs.h> | 32 | #include <linux/fs.h> |
33 | #include <linux/cdev.h> | 33 | #include <linux/cdev.h> |
34 | #include <linux/mutex.h> | 34 | #include <linux/mutex.h> |
35 | #include <linux/smp_lock.h> | ||
35 | #include "dvbdev.h" | 36 | #include "dvbdev.h" |
36 | 37 | ||
37 | static int dvbdev_debug; | 38 | static int dvbdev_debug; |
@@ -74,6 +75,7 @@ static int dvb_device_open(struct inode *inode, struct file *file) | |||
74 | { | 75 | { |
75 | struct dvb_device *dvbdev; | 76 | struct dvb_device *dvbdev; |
76 | 77 | ||
78 | lock_kernel(); | ||
77 | dvbdev = dvbdev_find_device (iminor(inode)); | 79 | dvbdev = dvbdev_find_device (iminor(inode)); |
78 | 80 | ||
79 | if (dvbdev && dvbdev->fops) { | 81 | if (dvbdev && dvbdev->fops) { |
@@ -90,8 +92,10 @@ static int dvb_device_open(struct inode *inode, struct file *file) | |||
90 | file->f_op = fops_get(old_fops); | 92 | file->f_op = fops_get(old_fops); |
91 | } | 93 | } |
92 | fops_put(old_fops); | 94 | fops_put(old_fops); |
95 | unlock_kernel(); | ||
93 | return err; | 96 | return err; |
94 | } | 97 | } |
98 | unlock_kernel(); | ||
95 | return -ENODEV; | 99 | return -ENODEV; |
96 | } | 100 | } |
97 | 101 | ||
diff --git a/drivers/media/radio/miropcm20-rds.c b/drivers/media/radio/miropcm20-rds.c index 06dfed9ef4c7..3e840f74d45c 100644 --- a/drivers/media/radio/miropcm20-rds.c +++ b/drivers/media/radio/miropcm20-rds.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/smp_lock.h> | ||
15 | #include <linux/fs.h> | 16 | #include <linux/fs.h> |
16 | #include <linux/miscdevice.h> | 17 | #include <linux/miscdevice.h> |
17 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
@@ -27,13 +28,16 @@ static int rds_f_open(struct inode *in, struct file *fi) | |||
27 | if (rds_users) | 28 | if (rds_users) |
28 | return -EBUSY; | 29 | return -EBUSY; |
29 | 30 | ||
31 | lock_kernel(); | ||
30 | rds_users++; | 32 | rds_users++; |
31 | if ((text_buffer=kmalloc(66, GFP_KERNEL)) == 0) { | 33 | if ((text_buffer=kmalloc(66, GFP_KERNEL)) == 0) { |
32 | rds_users--; | 34 | rds_users--; |
33 | printk(KERN_NOTICE "aci-rds: Out of memory by open()...\n"); | 35 | printk(KERN_NOTICE "aci-rds: Out of memory by open()...\n"); |
36 | unlock_kernel(); | ||
34 | return -ENOMEM; | 37 | return -ENOMEM; |
35 | } | 38 | } |
36 | 39 | ||
40 | unlock_kernel(); | ||
37 | return 0; | 41 | return 0; |
38 | } | 42 | } |
39 | 43 | ||
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c index 67a661cf5219..7649860a388d 100644 --- a/drivers/media/video/videodev.c +++ b/drivers/media/video/videodev.c | |||
@@ -36,6 +36,7 @@ | |||
36 | #include <linux/init.h> | 36 | #include <linux/init.h> |
37 | #include <linux/kmod.h> | 37 | #include <linux/kmod.h> |
38 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
39 | #include <linux/smp_lock.h> | ||
39 | #include <asm/uaccess.h> | 40 | #include <asm/uaccess.h> |
40 | #include <asm/system.h> | 41 | #include <asm/system.h> |
41 | 42 | ||
@@ -442,6 +443,7 @@ static int video_open(struct inode *inode, struct file *file) | |||
442 | 443 | ||
443 | if(minor>=VIDEO_NUM_DEVICES) | 444 | if(minor>=VIDEO_NUM_DEVICES) |
444 | return -ENODEV; | 445 | return -ENODEV; |
446 | lock_kernel(); | ||
445 | mutex_lock(&videodev_lock); | 447 | mutex_lock(&videodev_lock); |
446 | vfl=video_device[minor]; | 448 | vfl=video_device[minor]; |
447 | if(vfl==NULL) { | 449 | if(vfl==NULL) { |
@@ -451,6 +453,7 @@ static int video_open(struct inode *inode, struct file *file) | |||
451 | vfl=video_device[minor]; | 453 | vfl=video_device[minor]; |
452 | if (vfl==NULL) { | 454 | if (vfl==NULL) { |
453 | mutex_unlock(&videodev_lock); | 455 | mutex_unlock(&videodev_lock); |
456 | unlock_kernel(); | ||
454 | return -ENODEV; | 457 | return -ENODEV; |
455 | } | 458 | } |
456 | } | 459 | } |
@@ -464,6 +467,7 @@ static int video_open(struct inode *inode, struct file *file) | |||
464 | } | 467 | } |
465 | fops_put(old_fops); | 468 | fops_put(old_fops); |
466 | mutex_unlock(&videodev_lock); | 469 | mutex_unlock(&videodev_lock); |
470 | unlock_kernel(); | ||
467 | return err; | 471 | return err; |
468 | } | 472 | } |
469 | 473 | ||
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c index e630b50966ec..c5946560c4e2 100644 --- a/drivers/message/fusion/mptctl.c +++ b/drivers/message/fusion/mptctl.c | |||
@@ -548,11 +548,15 @@ static int | |||
548 | mptctl_fasync(int fd, struct file *filep, int mode) | 548 | mptctl_fasync(int fd, struct file *filep, int mode) |
549 | { | 549 | { |
550 | MPT_ADAPTER *ioc; | 550 | MPT_ADAPTER *ioc; |
551 | int ret; | ||
551 | 552 | ||
553 | lock_kernel(); | ||
552 | list_for_each_entry(ioc, &ioc_list, list) | 554 | list_for_each_entry(ioc, &ioc_list, list) |
553 | ioc->aen_event_read_flag=0; | 555 | ioc->aen_event_read_flag=0; |
554 | 556 | ||
555 | return fasync_helper(fd, filep, mode, &async_queue); | 557 | ret = fasync_helper(fd, filep, mode, &async_queue); |
558 | unlock_kernel(); | ||
559 | return ret; | ||
556 | } | 560 | } |
557 | 561 | ||
558 | static int | 562 | static int |
diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c index c0fb77dc19bb..4238de98d4a6 100644 --- a/drivers/message/i2o/i2o_config.c +++ b/drivers/message/i2o/i2o_config.c | |||
@@ -1061,6 +1061,7 @@ static int cfg_open(struct inode *inode, struct file *file) | |||
1061 | if (!tmp) | 1061 | if (!tmp) |
1062 | return -ENOMEM; | 1062 | return -ENOMEM; |
1063 | 1063 | ||
1064 | lock_kernel(); | ||
1064 | file->private_data = (void *)(i2o_cfg_info_id++); | 1065 | file->private_data = (void *)(i2o_cfg_info_id++); |
1065 | tmp->fp = file; | 1066 | tmp->fp = file; |
1066 | tmp->fasync = NULL; | 1067 | tmp->fasync = NULL; |
@@ -1074,6 +1075,7 @@ static int cfg_open(struct inode *inode, struct file *file) | |||
1074 | spin_lock_irqsave(&i2o_config_lock, flags); | 1075 | spin_lock_irqsave(&i2o_config_lock, flags); |
1075 | open_files = tmp; | 1076 | open_files = tmp; |
1076 | spin_unlock_irqrestore(&i2o_config_lock, flags); | 1077 | spin_unlock_irqrestore(&i2o_config_lock, flags); |
1078 | unlock_kernel(); | ||
1077 | 1079 | ||
1078 | return 0; | 1080 | return 0; |
1079 | } | 1081 | } |
@@ -1082,15 +1084,17 @@ static int cfg_fasync(int fd, struct file *fp, int on) | |||
1082 | { | 1084 | { |
1083 | ulong id = (ulong) fp->private_data; | 1085 | ulong id = (ulong) fp->private_data; |
1084 | struct i2o_cfg_info *p; | 1086 | struct i2o_cfg_info *p; |
1087 | int ret = -EBADF; | ||
1085 | 1088 | ||
1089 | lock_kernel(); | ||
1086 | for (p = open_files; p; p = p->next) | 1090 | for (p = open_files; p; p = p->next) |
1087 | if (p->q_id == id) | 1091 | if (p->q_id == id) |
1088 | break; | 1092 | break; |
1089 | 1093 | ||
1090 | if (!p) | 1094 | if (p) |
1091 | return -EBADF; | 1095 | ret = fasync_helper(fd, fp, on, &p->fasync); |
1092 | 1096 | unlock_kernel(); | |
1093 | return fasync_helper(fd, fp, on, &p->fasync); | 1097 | return ret; |
1094 | } | 1098 | } |
1095 | 1099 | ||
1096 | static int cfg_release(struct inode *inode, struct file *file) | 1100 | static int cfg_release(struct inode *inode, struct file *file) |
diff --git a/drivers/misc/hdpuftrs/hdpu_cpustate.c b/drivers/misc/hdpuftrs/hdpu_cpustate.c index ff51ab67231c..176fe4e09d3f 100644 --- a/drivers/misc/hdpuftrs/hdpu_cpustate.c +++ b/drivers/misc/hdpuftrs/hdpu_cpustate.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/spinlock.h> | 19 | #include <linux/spinlock.h> |
20 | #include <linux/smp_lock.h> | ||
20 | #include <linux/miscdevice.h> | 21 | #include <linux/miscdevice.h> |
21 | #include <linux/proc_fs.h> | 22 | #include <linux/proc_fs.h> |
22 | #include <linux/hdpu_features.h> | 23 | #include <linux/hdpu_features.h> |
@@ -151,7 +152,13 @@ static ssize_t cpustate_write(struct file *file, const char *buf, | |||
151 | 152 | ||
152 | static int cpustate_open(struct inode *inode, struct file *file) | 153 | static int cpustate_open(struct inode *inode, struct file *file) |
153 | { | 154 | { |
154 | return cpustate_get_ref((file->f_flags & O_EXCL)); | 155 | int ret; |
156 | |||
157 | lock_kernel(); | ||
158 | ret = cpustate_get_ref((file->f_flags & O_EXCL)); | ||
159 | unlock_kernel(); | ||
160 | |||
161 | return ret; | ||
155 | } | 162 | } |
156 | 163 | ||
157 | static int cpustate_release(struct inode *inode, struct file *file) | 164 | static int cpustate_release(struct inode *inode, struct file *file) |
diff --git a/drivers/misc/phantom.c b/drivers/misc/phantom.c index 71d1c84e2fa8..186162470090 100644 --- a/drivers/misc/phantom.c +++ b/drivers/misc/phantom.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/interrupt.h> | 22 | #include <linux/interrupt.h> |
23 | #include <linux/cdev.h> | 23 | #include <linux/cdev.h> |
24 | #include <linux/phantom.h> | 24 | #include <linux/phantom.h> |
25 | #include <linux/smp_lock.h> | ||
25 | 26 | ||
26 | #include <asm/atomic.h> | 27 | #include <asm/atomic.h> |
27 | #include <asm/io.h> | 28 | #include <asm/io.h> |
@@ -212,13 +213,17 @@ static int phantom_open(struct inode *inode, struct file *file) | |||
212 | struct phantom_device *dev = container_of(inode->i_cdev, | 213 | struct phantom_device *dev = container_of(inode->i_cdev, |
213 | struct phantom_device, cdev); | 214 | struct phantom_device, cdev); |
214 | 215 | ||
216 | lock_kernel(); | ||
215 | nonseekable_open(inode, file); | 217 | nonseekable_open(inode, file); |
216 | 218 | ||
217 | if (mutex_lock_interruptible(&dev->open_lock)) | 219 | if (mutex_lock_interruptible(&dev->open_lock)) { |
220 | unlock_kernel(); | ||
218 | return -ERESTARTSYS; | 221 | return -ERESTARTSYS; |
222 | } | ||
219 | 223 | ||
220 | if (dev->opened) { | 224 | if (dev->opened) { |
221 | mutex_unlock(&dev->open_lock); | 225 | mutex_unlock(&dev->open_lock); |
226 | unlock_kernel(); | ||
222 | return -EINVAL; | 227 | return -EINVAL; |
223 | } | 228 | } |
224 | 229 | ||
@@ -229,7 +234,7 @@ static int phantom_open(struct inode *inode, struct file *file) | |||
229 | atomic_set(&dev->counter, 0); | 234 | atomic_set(&dev->counter, 0); |
230 | dev->opened++; | 235 | dev->opened++; |
231 | mutex_unlock(&dev->open_lock); | 236 | mutex_unlock(&dev->open_lock); |
232 | 237 | unlock_kernel(); | |
233 | return 0; | 238 | return 0; |
234 | } | 239 | } |
235 | 240 | ||
diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c index 00e48e2a9c11..60775be22822 100644 --- a/drivers/misc/sony-laptop.c +++ b/drivers/misc/sony-laptop.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/module.h> | 46 | #include <linux/module.h> |
47 | #include <linux/moduleparam.h> | 47 | #include <linux/moduleparam.h> |
48 | #include <linux/init.h> | 48 | #include <linux/init.h> |
49 | #include <linux/smp_lock.h> | ||
49 | #include <linux/types.h> | 50 | #include <linux/types.h> |
50 | #include <linux/backlight.h> | 51 | #include <linux/backlight.h> |
51 | #include <linux/platform_device.h> | 52 | #include <linux/platform_device.h> |
@@ -1927,8 +1928,10 @@ static int sonypi_misc_release(struct inode *inode, struct file *file) | |||
1927 | static int sonypi_misc_open(struct inode *inode, struct file *file) | 1928 | static int sonypi_misc_open(struct inode *inode, struct file *file) |
1928 | { | 1929 | { |
1929 | /* Flush input queue on first open */ | 1930 | /* Flush input queue on first open */ |
1931 | lock_kernel(); | ||
1930 | if (atomic_inc_return(&sonypi_compat.open_count) == 1) | 1932 | if (atomic_inc_return(&sonypi_compat.open_count) == 1) |
1931 | kfifo_reset(sonypi_compat.fifo); | 1933 | kfifo_reset(sonypi_compat.fifo); |
1934 | unlock_kernel(); | ||
1932 | return 0; | 1935 | return 0; |
1933 | } | 1936 | } |
1934 | 1937 | ||
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 5d3ac512ce16..129d429cd2da 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
16 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
17 | #include <linux/smp_lock.h> | ||
17 | 18 | ||
18 | #include <linux/mtd/mtd.h> | 19 | #include <linux/mtd/mtd.h> |
19 | #include <linux/mtd/compatmac.h> | 20 | #include <linux/mtd/compatmac.h> |
@@ -86,6 +87,7 @@ static int mtd_open(struct inode *inode, struct file *file) | |||
86 | { | 87 | { |
87 | int minor = iminor(inode); | 88 | int minor = iminor(inode); |
88 | int devnum = minor >> 1; | 89 | int devnum = minor >> 1; |
90 | int ret = 0; | ||
89 | struct mtd_info *mtd; | 91 | struct mtd_info *mtd; |
90 | struct mtd_file_info *mfi; | 92 | struct mtd_file_info *mfi; |
91 | 93 | ||
@@ -98,31 +100,39 @@ static int mtd_open(struct inode *inode, struct file *file) | |||
98 | if ((file->f_mode & 2) && (minor & 1)) | 100 | if ((file->f_mode & 2) && (minor & 1)) |
99 | return -EACCES; | 101 | return -EACCES; |
100 | 102 | ||
103 | lock_kernel(); | ||
101 | mtd = get_mtd_device(NULL, devnum); | 104 | mtd = get_mtd_device(NULL, devnum); |
102 | 105 | ||
103 | if (IS_ERR(mtd)) | 106 | if (IS_ERR(mtd)) { |
104 | return PTR_ERR(mtd); | 107 | ret = PTR_ERR(mtd); |
108 | goto out; | ||
109 | } | ||
105 | 110 | ||
106 | if (MTD_ABSENT == mtd->type) { | 111 | if (MTD_ABSENT == mtd->type) { |
107 | put_mtd_device(mtd); | 112 | put_mtd_device(mtd); |
108 | return -ENODEV; | 113 | ret = -ENODEV; |
114 | goto out; | ||
109 | } | 115 | } |
110 | 116 | ||
111 | /* You can't open it RW if it's not a writeable device */ | 117 | /* You can't open it RW if it's not a writeable device */ |
112 | if ((file->f_mode & 2) && !(mtd->flags & MTD_WRITEABLE)) { | 118 | if ((file->f_mode & 2) && !(mtd->flags & MTD_WRITEABLE)) { |
113 | put_mtd_device(mtd); | 119 | put_mtd_device(mtd); |
114 | return -EACCES; | 120 | ret = -EACCES; |
121 | goto out; | ||
115 | } | 122 | } |
116 | 123 | ||
117 | mfi = kzalloc(sizeof(*mfi), GFP_KERNEL); | 124 | mfi = kzalloc(sizeof(*mfi), GFP_KERNEL); |
118 | if (!mfi) { | 125 | if (!mfi) { |
119 | put_mtd_device(mtd); | 126 | put_mtd_device(mtd); |
120 | return -ENOMEM; | 127 | ret = -ENOMEM; |
128 | goto out; | ||
121 | } | 129 | } |
122 | mfi->mtd = mtd; | 130 | mfi->mtd = mtd; |
123 | file->private_data = mfi; | 131 | file->private_data = mfi; |
124 | 132 | ||
125 | return 0; | 133 | out: |
134 | unlock_kernel(); | ||
135 | return ret; | ||
126 | } /* mtd_open */ | 136 | } /* mtd_open */ |
127 | 137 | ||
128 | /*====================================================================*/ | 138 | /*====================================================================*/ |
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c index 9d6aae5449b6..89193ba9451e 100644 --- a/drivers/mtd/ubi/cdev.c +++ b/drivers/mtd/ubi/cdev.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/stat.h> | 39 | #include <linux/stat.h> |
40 | #include <linux/ioctl.h> | 40 | #include <linux/ioctl.h> |
41 | #include <linux/capability.h> | 41 | #include <linux/capability.h> |
42 | #include <linux/smp_lock.h> | ||
42 | #include <mtd/ubi-user.h> | 43 | #include <mtd/ubi-user.h> |
43 | #include <asm/uaccess.h> | 44 | #include <asm/uaccess.h> |
44 | #include <asm/div64.h> | 45 | #include <asm/div64.h> |
@@ -103,9 +104,12 @@ static int vol_cdev_open(struct inode *inode, struct file *file) | |||
103 | struct ubi_volume_desc *desc; | 104 | struct ubi_volume_desc *desc; |
104 | int vol_id = iminor(inode) - 1, mode, ubi_num; | 105 | int vol_id = iminor(inode) - 1, mode, ubi_num; |
105 | 106 | ||
107 | lock_kernel(); | ||
106 | ubi_num = ubi_major2num(imajor(inode)); | 108 | ubi_num = ubi_major2num(imajor(inode)); |
107 | if (ubi_num < 0) | 109 | if (ubi_num < 0) { |
110 | unlock_kernel(); | ||
108 | return ubi_num; | 111 | return ubi_num; |
112 | } | ||
109 | 113 | ||
110 | if (file->f_mode & FMODE_WRITE) | 114 | if (file->f_mode & FMODE_WRITE) |
111 | mode = UBI_READWRITE; | 115 | mode = UBI_READWRITE; |
@@ -115,6 +119,7 @@ static int vol_cdev_open(struct inode *inode, struct file *file) | |||
115 | dbg_msg("open volume %d, mode %d", vol_id, mode); | 119 | dbg_msg("open volume %d, mode %d", vol_id, mode); |
116 | 120 | ||
117 | desc = ubi_open_volume(ubi_num, vol_id, mode); | 121 | desc = ubi_open_volume(ubi_num, vol_id, mode); |
122 | unlock_kernel(); | ||
118 | if (IS_ERR(desc)) | 123 | if (IS_ERR(desc)) |
119 | return PTR_ERR(desc); | 124 | return PTR_ERR(desc); |
120 | 125 | ||
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c index 1f4ca2b54a73..83625fdff3dd 100644 --- a/drivers/net/ppp_generic.c +++ b/drivers/net/ppp_generic.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <linux/if_arp.h> | 39 | #include <linux/if_arp.h> |
40 | #include <linux/ip.h> | 40 | #include <linux/ip.h> |
41 | #include <linux/tcp.h> | 41 | #include <linux/tcp.h> |
42 | #include <linux/smp_lock.h> | ||
42 | #include <linux/spinlock.h> | 43 | #include <linux/spinlock.h> |
43 | #include <linux/rwsem.h> | 44 | #include <linux/rwsem.h> |
44 | #include <linux/stddef.h> | 45 | #include <linux/stddef.h> |
@@ -353,6 +354,7 @@ static const int npindex_to_ethertype[NUM_NP] = { | |||
353 | */ | 354 | */ |
354 | static int ppp_open(struct inode *inode, struct file *file) | 355 | static int ppp_open(struct inode *inode, struct file *file) |
355 | { | 356 | { |
357 | cycle_kernel_lock(); | ||
356 | /* | 358 | /* |
357 | * This could (should?) be enforced by the permissions on /dev/ppp. | 359 | * This could (should?) be enforced by the permissions on /dev/ppp. |
358 | */ | 360 | */ |
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index b9018bfa0a97..eba1271b9735 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include <linux/kernel.h> | 48 | #include <linux/kernel.h> |
49 | #include <linux/major.h> | 49 | #include <linux/major.h> |
50 | #include <linux/slab.h> | 50 | #include <linux/slab.h> |
51 | #include <linux/smp_lock.h> | ||
51 | #include <linux/poll.h> | 52 | #include <linux/poll.h> |
52 | #include <linux/fcntl.h> | 53 | #include <linux/fcntl.h> |
53 | #include <linux/init.h> | 54 | #include <linux/init.h> |
@@ -802,22 +803,26 @@ static int tun_chr_fasync(int fd, struct file *file, int on) | |||
802 | 803 | ||
803 | DBG(KERN_INFO "%s: tun_chr_fasync %d\n", tun->dev->name, on); | 804 | DBG(KERN_INFO "%s: tun_chr_fasync %d\n", tun->dev->name, on); |
804 | 805 | ||
806 | lock_kernel(); | ||
805 | if ((ret = fasync_helper(fd, file, on, &tun->fasync)) < 0) | 807 | if ((ret = fasync_helper(fd, file, on, &tun->fasync)) < 0) |
806 | return ret; | 808 | goto out; |
807 | 809 | ||
808 | if (on) { | 810 | if (on) { |
809 | ret = __f_setown(file, task_pid(current), PIDTYPE_PID, 0); | 811 | ret = __f_setown(file, task_pid(current), PIDTYPE_PID, 0); |
810 | if (ret) | 812 | if (ret) |
811 | return ret; | 813 | goto out; |
812 | tun->flags |= TUN_FASYNC; | 814 | tun->flags |= TUN_FASYNC; |
813 | } else | 815 | } else |
814 | tun->flags &= ~TUN_FASYNC; | 816 | tun->flags &= ~TUN_FASYNC; |
815 | 817 | ret = 0; | |
816 | return 0; | 818 | out: |
819 | unlock_kernel(); | ||
820 | return ret; | ||
817 | } | 821 | } |
818 | 822 | ||
819 | static int tun_chr_open(struct inode *inode, struct file * file) | 823 | static int tun_chr_open(struct inode *inode, struct file * file) |
820 | { | 824 | { |
825 | cycle_kernel_lock(); | ||
821 | DBG1(KERN_INFO "tunX: tun_chr_open\n"); | 826 | DBG1(KERN_INFO "tunX: tun_chr_open\n"); |
822 | file->private_data = NULL; | 827 | file->private_data = NULL; |
823 | return 0; | 828 | return 0; |
diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c index b0fce1387eaf..5827324e9d9f 100644 --- a/drivers/net/wan/cosa.c +++ b/drivers/net/wan/cosa.c | |||
@@ -92,6 +92,7 @@ | |||
92 | #include <linux/spinlock.h> | 92 | #include <linux/spinlock.h> |
93 | #include <linux/mutex.h> | 93 | #include <linux/mutex.h> |
94 | #include <linux/device.h> | 94 | #include <linux/device.h> |
95 | #include <linux/smp_lock.h> | ||
95 | 96 | ||
96 | #undef COSA_SLOW_IO /* for testing purposes only */ | 97 | #undef COSA_SLOW_IO /* for testing purposes only */ |
97 | 98 | ||
@@ -970,15 +971,21 @@ static int cosa_open(struct inode *inode, struct file *file) | |||
970 | struct channel_data *chan; | 971 | struct channel_data *chan; |
971 | unsigned long flags; | 972 | unsigned long flags; |
972 | int n; | 973 | int n; |
974 | int ret = 0; | ||
973 | 975 | ||
976 | lock_kernel(); | ||
974 | if ((n=iminor(file->f_path.dentry->d_inode)>>CARD_MINOR_BITS) | 977 | if ((n=iminor(file->f_path.dentry->d_inode)>>CARD_MINOR_BITS) |
975 | >= nr_cards) | 978 | >= nr_cards) { |
976 | return -ENODEV; | 979 | ret = -ENODEV; |
980 | goto out; | ||
981 | } | ||
977 | cosa = cosa_cards+n; | 982 | cosa = cosa_cards+n; |
978 | 983 | ||
979 | if ((n=iminor(file->f_path.dentry->d_inode) | 984 | if ((n=iminor(file->f_path.dentry->d_inode) |
980 | & ((1<<CARD_MINOR_BITS)-1)) >= cosa->nchannels) | 985 | & ((1<<CARD_MINOR_BITS)-1)) >= cosa->nchannels) { |
981 | return -ENODEV; | 986 | ret = -ENODEV; |
987 | goto out; | ||
988 | } | ||
982 | chan = cosa->chan + n; | 989 | chan = cosa->chan + n; |
983 | 990 | ||
984 | file->private_data = chan; | 991 | file->private_data = chan; |
@@ -987,7 +994,8 @@ static int cosa_open(struct inode *inode, struct file *file) | |||
987 | 994 | ||
988 | if (chan->usage < 0) { /* in netdev mode */ | 995 | if (chan->usage < 0) { /* in netdev mode */ |
989 | spin_unlock_irqrestore(&cosa->lock, flags); | 996 | spin_unlock_irqrestore(&cosa->lock, flags); |
990 | return -EBUSY; | 997 | ret = -EBUSY; |
998 | goto out; | ||
991 | } | 999 | } |
992 | cosa->usage++; | 1000 | cosa->usage++; |
993 | chan->usage++; | 1001 | chan->usage++; |
@@ -996,7 +1004,9 @@ static int cosa_open(struct inode *inode, struct file *file) | |||
996 | chan->setup_rx = chrdev_setup_rx; | 1004 | chan->setup_rx = chrdev_setup_rx; |
997 | chan->rx_done = chrdev_rx_done; | 1005 | chan->rx_done = chrdev_rx_done; |
998 | spin_unlock_irqrestore(&cosa->lock, flags); | 1006 | spin_unlock_irqrestore(&cosa->lock, flags); |
999 | return 0; | 1007 | out: |
1008 | unlock_kernel(); | ||
1009 | return ret; | ||
1000 | } | 1010 | } |
1001 | 1011 | ||
1002 | static int cosa_release(struct inode *inode, struct file *file) | 1012 | static int cosa_release(struct inode *inode, struct file *file) |
diff --git a/drivers/parisc/eisa_eeprom.c b/drivers/parisc/eisa_eeprom.c index 86e9c84a965e..5ac207932fd7 100644 --- a/drivers/parisc/eisa_eeprom.c +++ b/drivers/parisc/eisa_eeprom.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | #include <linux/miscdevice.h> | 25 | #include <linux/miscdevice.h> |
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/smp_lock.h> | ||
27 | #include <linux/fs.h> | 28 | #include <linux/fs.h> |
28 | #include <asm/io.h> | 29 | #include <asm/io.h> |
29 | #include <asm/uaccess.h> | 30 | #include <asm/uaccess.h> |
@@ -83,6 +84,8 @@ static int eisa_eeprom_ioctl(struct inode *inode, struct file *file, | |||
83 | 84 | ||
84 | static int eisa_eeprom_open(struct inode *inode, struct file *file) | 85 | static int eisa_eeprom_open(struct inode *inode, struct file *file) |
85 | { | 86 | { |
87 | cycle_kernel_lock(); | ||
88 | |||
86 | if (file->f_mode & 2) | 89 | if (file->f_mode & 2) |
87 | return -EINVAL; | 90 | return -EINVAL; |
88 | 91 | ||
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index afd00e7bbbef..419f97fc9a62 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/proc_fs.h> | 27 | #include <linux/proc_fs.h> |
28 | #include <linux/poll.h> | 28 | #include <linux/poll.h> |
29 | #include <linux/pci.h> | 29 | #include <linux/pci.h> |
30 | #include <linux/smp_lock.h> | ||
30 | #include <linux/workqueue.h> | 31 | #include <linux/workqueue.h> |
31 | 32 | ||
32 | #include <pcmcia/cs_types.h> | 33 | #include <pcmcia/cs_types.h> |
@@ -545,20 +546,27 @@ static int ds_open(struct inode *inode, struct file *file) | |||
545 | struct pcmcia_socket *s; | 546 | struct pcmcia_socket *s; |
546 | user_info_t *user; | 547 | user_info_t *user; |
547 | static int warning_printed = 0; | 548 | static int warning_printed = 0; |
549 | int ret = 0; | ||
548 | 550 | ||
549 | ds_dbg(0, "ds_open(socket %d)\n", i); | 551 | ds_dbg(0, "ds_open(socket %d)\n", i); |
550 | 552 | ||
553 | lock_kernel(); | ||
551 | s = pcmcia_get_socket_by_nr(i); | 554 | s = pcmcia_get_socket_by_nr(i); |
552 | if (!s) | 555 | if (!s) { |
553 | return -ENODEV; | 556 | ret = -ENODEV; |
557 | goto out; | ||
558 | } | ||
554 | s = pcmcia_get_socket(s); | 559 | s = pcmcia_get_socket(s); |
555 | if (!s) | 560 | if (!s) { |
556 | return -ENODEV; | 561 | ret = -ENODEV; |
562 | goto out; | ||
563 | } | ||
557 | 564 | ||
558 | if ((file->f_flags & O_ACCMODE) != O_RDONLY) { | 565 | if ((file->f_flags & O_ACCMODE) != O_RDONLY) { |
559 | if (s->pcmcia_state.busy) { | 566 | if (s->pcmcia_state.busy) { |
560 | pcmcia_put_socket(s); | 567 | pcmcia_put_socket(s); |
561 | return -EBUSY; | 568 | ret = -EBUSY; |
569 | goto out; | ||
562 | } | 570 | } |
563 | else | 571 | else |
564 | s->pcmcia_state.busy = 1; | 572 | s->pcmcia_state.busy = 1; |
@@ -567,7 +575,8 @@ static int ds_open(struct inode *inode, struct file *file) | |||
567 | user = kmalloc(sizeof(user_info_t), GFP_KERNEL); | 575 | user = kmalloc(sizeof(user_info_t), GFP_KERNEL); |
568 | if (!user) { | 576 | if (!user) { |
569 | pcmcia_put_socket(s); | 577 | pcmcia_put_socket(s); |
570 | return -ENOMEM; | 578 | ret = -ENOMEM; |
579 | goto out; | ||
571 | } | 580 | } |
572 | user->event_tail = user->event_head = 0; | 581 | user->event_tail = user->event_head = 0; |
573 | user->next = s->user; | 582 | user->next = s->user; |
@@ -589,7 +598,9 @@ static int ds_open(struct inode *inode, struct file *file) | |||
589 | 598 | ||
590 | if (s->pcmcia_state.present) | 599 | if (s->pcmcia_state.present) |
591 | queue_event(user, CS_EVENT_CARD_INSERTION); | 600 | queue_event(user, CS_EVENT_CARD_INSERTION); |
592 | return 0; | 601 | out: |
602 | unlock_kernel(); | ||
603 | return ret; | ||
593 | } /* ds_open */ | 604 | } /* ds_open */ |
594 | 605 | ||
595 | /*====================================================================*/ | 606 | /*====================================================================*/ |
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c index 90dfa0df747a..0114a78b7cbb 100644 --- a/drivers/rtc/rtc-dev.c +++ b/drivers/rtc/rtc-dev.c | |||
@@ -13,6 +13,7 @@ | |||
13 | 13 | ||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/rtc.h> | 15 | #include <linux/rtc.h> |
16 | #include <linux/smp_lock.h> | ||
16 | #include "rtc-core.h" | 17 | #include "rtc-core.h" |
17 | 18 | ||
18 | static dev_t rtc_devt; | 19 | static dev_t rtc_devt; |
@@ -26,8 +27,11 @@ static int rtc_dev_open(struct inode *inode, struct file *file) | |||
26 | struct rtc_device, char_dev); | 27 | struct rtc_device, char_dev); |
27 | const struct rtc_class_ops *ops = rtc->ops; | 28 | const struct rtc_class_ops *ops = rtc->ops; |
28 | 29 | ||
29 | if (test_and_set_bit_lock(RTC_DEV_BUSY, &rtc->flags)) | 30 | lock_kernel(); |
30 | return -EBUSY; | 31 | if (test_and_set_bit_lock(RTC_DEV_BUSY, &rtc->flags)) { |
32 | err = -EBUSY; | ||
33 | goto out; | ||
34 | } | ||
31 | 35 | ||
32 | file->private_data = rtc; | 36 | file->private_data = rtc; |
33 | 37 | ||
@@ -37,11 +41,13 @@ static int rtc_dev_open(struct inode *inode, struct file *file) | |||
37 | rtc->irq_data = 0; | 41 | rtc->irq_data = 0; |
38 | spin_unlock_irq(&rtc->irq_lock); | 42 | spin_unlock_irq(&rtc->irq_lock); |
39 | 43 | ||
40 | return 0; | 44 | goto out; |
41 | } | 45 | } |
42 | 46 | ||
43 | /* something has gone wrong */ | 47 | /* something has gone wrong */ |
44 | clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags); | 48 | clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags); |
49 | out: | ||
50 | unlock_kernel(); | ||
45 | return err; | 51 | return err; |
46 | } | 52 | } |
47 | 53 | ||
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index a3e0880b38fb..0a19c06019be 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | #include <linux/smp_lock.h> | ||
20 | #include <linux/string.h> | 21 | #include <linux/string.h> |
21 | #include <linux/i2c.h> | 22 | #include <linux/i2c.h> |
22 | #include <linux/rtc.h> | 23 | #include <linux/rtc.h> |
@@ -655,12 +656,16 @@ static int wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, | |||
655 | static int wdt_open(struct inode *inode, struct file *file) | 656 | static int wdt_open(struct inode *inode, struct file *file) |
656 | { | 657 | { |
657 | if (MINOR(inode->i_rdev) == WATCHDOG_MINOR) { | 658 | if (MINOR(inode->i_rdev) == WATCHDOG_MINOR) { |
658 | if (test_and_set_bit(0, &wdt_is_open)) | 659 | lock_kernel(); |
660 | if (test_and_set_bit(0, &wdt_is_open)) { | ||
661 | unlock_kernel(); | ||
659 | return -EBUSY; | 662 | return -EBUSY; |
663 | } | ||
660 | /* | 664 | /* |
661 | * Activate | 665 | * Activate |
662 | */ | 666 | */ |
663 | wdt_is_open = 1; | 667 | wdt_is_open = 1; |
668 | unlock_kernel(); | ||
664 | return 0; | 669 | return 0; |
665 | } | 670 | } |
666 | return -ENODEV; | 671 | return -ENODEV; |
diff --git a/drivers/s390/block/dasd_eer.c b/drivers/s390/block/dasd_eer.c index 6e53ab606e97..29da4413ad43 100644 --- a/drivers/s390/block/dasd_eer.c +++ b/drivers/s390/block/dasd_eer.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/device.h> | 15 | #include <linux/device.h> |
16 | #include <linux/poll.h> | 16 | #include <linux/poll.h> |
17 | #include <linux/mutex.h> | 17 | #include <linux/mutex.h> |
18 | #include <linux/smp_lock.h> | ||
18 | 19 | ||
19 | #include <asm/uaccess.h> | 20 | #include <asm/uaccess.h> |
20 | #include <asm/atomic.h> | 21 | #include <asm/atomic.h> |
@@ -525,6 +526,7 @@ static int dasd_eer_open(struct inode *inp, struct file *filp) | |||
525 | eerb = kzalloc(sizeof(struct eerbuffer), GFP_KERNEL); | 526 | eerb = kzalloc(sizeof(struct eerbuffer), GFP_KERNEL); |
526 | if (!eerb) | 527 | if (!eerb) |
527 | return -ENOMEM; | 528 | return -ENOMEM; |
529 | lock_kernel(); | ||
528 | eerb->buffer_page_count = eer_pages; | 530 | eerb->buffer_page_count = eer_pages; |
529 | if (eerb->buffer_page_count < 1 || | 531 | if (eerb->buffer_page_count < 1 || |
530 | eerb->buffer_page_count > INT_MAX / PAGE_SIZE) { | 532 | eerb->buffer_page_count > INT_MAX / PAGE_SIZE) { |
@@ -532,6 +534,7 @@ static int dasd_eer_open(struct inode *inp, struct file *filp) | |||
532 | MESSAGE(KERN_WARNING, "can't open device since module " | 534 | MESSAGE(KERN_WARNING, "can't open device since module " |
533 | "parameter eer_pages is smaller then 1 or" | 535 | "parameter eer_pages is smaller then 1 or" |
534 | " bigger then %d", (int)(INT_MAX / PAGE_SIZE)); | 536 | " bigger then %d", (int)(INT_MAX / PAGE_SIZE)); |
537 | unlock_kernel(); | ||
535 | return -EINVAL; | 538 | return -EINVAL; |
536 | } | 539 | } |
537 | eerb->buffersize = eerb->buffer_page_count * PAGE_SIZE; | 540 | eerb->buffersize = eerb->buffer_page_count * PAGE_SIZE; |
@@ -539,12 +542,14 @@ static int dasd_eer_open(struct inode *inp, struct file *filp) | |||
539 | GFP_KERNEL); | 542 | GFP_KERNEL); |
540 | if (!eerb->buffer) { | 543 | if (!eerb->buffer) { |
541 | kfree(eerb); | 544 | kfree(eerb); |
545 | unlock_kernel(); | ||
542 | return -ENOMEM; | 546 | return -ENOMEM; |
543 | } | 547 | } |
544 | if (dasd_eer_allocate_buffer_pages(eerb->buffer, | 548 | if (dasd_eer_allocate_buffer_pages(eerb->buffer, |
545 | eerb->buffer_page_count)) { | 549 | eerb->buffer_page_count)) { |
546 | kfree(eerb->buffer); | 550 | kfree(eerb->buffer); |
547 | kfree(eerb); | 551 | kfree(eerb); |
552 | unlock_kernel(); | ||
548 | return -ENOMEM; | 553 | return -ENOMEM; |
549 | } | 554 | } |
550 | filp->private_data = eerb; | 555 | filp->private_data = eerb; |
@@ -552,6 +557,7 @@ static int dasd_eer_open(struct inode *inp, struct file *filp) | |||
552 | list_add(&eerb->list, &bufferlist); | 557 | list_add(&eerb->list, &bufferlist); |
553 | spin_unlock_irqrestore(&bufferlock, flags); | 558 | spin_unlock_irqrestore(&bufferlock, flags); |
554 | 559 | ||
560 | unlock_kernel(); | ||
555 | return nonseekable_open(inp,filp); | 561 | return nonseekable_open(inp,filp); |
556 | } | 562 | } |
557 | 563 | ||
diff --git a/drivers/s390/char/fs3270.c b/drivers/s390/char/fs3270.c index e136d10a0de6..d18e6d2e0b49 100644 --- a/drivers/s390/char/fs3270.c +++ b/drivers/s390/char/fs3270.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/interrupt.h> | 14 | #include <linux/interrupt.h> |
15 | #include <linux/list.h> | 15 | #include <linux/list.h> |
16 | #include <linux/types.h> | 16 | #include <linux/types.h> |
17 | #include <linux/smp_lock.h> | ||
17 | 18 | ||
18 | #include <asm/ccwdev.h> | 19 | #include <asm/ccwdev.h> |
19 | #include <asm/cio.h> | 20 | #include <asm/cio.h> |
@@ -421,6 +422,7 @@ fs3270_open(struct inode *inode, struct file *filp) | |||
421 | 422 | ||
422 | if (imajor(filp->f_path.dentry->d_inode) != IBM_FS3270_MAJOR) | 423 | if (imajor(filp->f_path.dentry->d_inode) != IBM_FS3270_MAJOR) |
423 | return -ENODEV; | 424 | return -ENODEV; |
425 | lock_kernel(); | ||
424 | minor = iminor(filp->f_path.dentry->d_inode); | 426 | minor = iminor(filp->f_path.dentry->d_inode); |
425 | /* Check for minor 0 multiplexer. */ | 427 | /* Check for minor 0 multiplexer. */ |
426 | if (minor == 0) { | 428 | if (minor == 0) { |
@@ -429,7 +431,8 @@ fs3270_open(struct inode *inode, struct file *filp) | |||
429 | tty = get_current_tty(); | 431 | tty = get_current_tty(); |
430 | if (!tty || tty->driver->major != IBM_TTY3270_MAJOR) { | 432 | if (!tty || tty->driver->major != IBM_TTY3270_MAJOR) { |
431 | mutex_unlock(&tty_mutex); | 433 | mutex_unlock(&tty_mutex); |
432 | return -ENODEV; | 434 | rc = -ENODEV; |
435 | goto out; | ||
433 | } | 436 | } |
434 | minor = tty->index + RAW3270_FIRSTMINOR; | 437 | minor = tty->index + RAW3270_FIRSTMINOR; |
435 | mutex_unlock(&tty_mutex); | 438 | mutex_unlock(&tty_mutex); |
@@ -438,19 +441,22 @@ fs3270_open(struct inode *inode, struct file *filp) | |||
438 | fp = (struct fs3270 *) raw3270_find_view(&fs3270_fn, minor); | 441 | fp = (struct fs3270 *) raw3270_find_view(&fs3270_fn, minor); |
439 | if (!IS_ERR(fp)) { | 442 | if (!IS_ERR(fp)) { |
440 | raw3270_put_view(&fp->view); | 443 | raw3270_put_view(&fp->view); |
441 | return -EBUSY; | 444 | rc = -EBUSY; |
445 | goto out; | ||
442 | } | 446 | } |
443 | /* Allocate fullscreen view structure. */ | 447 | /* Allocate fullscreen view structure. */ |
444 | fp = fs3270_alloc_view(); | 448 | fp = fs3270_alloc_view(); |
445 | if (IS_ERR(fp)) | 449 | if (IS_ERR(fp)) { |
446 | return PTR_ERR(fp); | 450 | rc = PTR_ERR(fp); |
451 | goto out; | ||
452 | } | ||
447 | 453 | ||
448 | init_waitqueue_head(&fp->wait); | 454 | init_waitqueue_head(&fp->wait); |
449 | fp->fs_pid = get_pid(task_pid(current)); | 455 | fp->fs_pid = get_pid(task_pid(current)); |
450 | rc = raw3270_add_view(&fp->view, &fs3270_fn, minor); | 456 | rc = raw3270_add_view(&fp->view, &fs3270_fn, minor); |
451 | if (rc) { | 457 | if (rc) { |
452 | fs3270_free_view(&fp->view); | 458 | fs3270_free_view(&fp->view); |
453 | return rc; | 459 | goto out; |
454 | } | 460 | } |
455 | 461 | ||
456 | /* Allocate idal-buffer. */ | 462 | /* Allocate idal-buffer. */ |
@@ -458,7 +464,8 @@ fs3270_open(struct inode *inode, struct file *filp) | |||
458 | if (IS_ERR(ib)) { | 464 | if (IS_ERR(ib)) { |
459 | raw3270_put_view(&fp->view); | 465 | raw3270_put_view(&fp->view); |
460 | raw3270_del_view(&fp->view); | 466 | raw3270_del_view(&fp->view); |
461 | return PTR_ERR(fp); | 467 | rc = PTR_ERR(fp); |
468 | goto out; | ||
462 | } | 469 | } |
463 | fp->rdbuf = ib; | 470 | fp->rdbuf = ib; |
464 | 471 | ||
@@ -466,9 +473,11 @@ fs3270_open(struct inode *inode, struct file *filp) | |||
466 | if (rc) { | 473 | if (rc) { |
467 | raw3270_put_view(&fp->view); | 474 | raw3270_put_view(&fp->view); |
468 | raw3270_del_view(&fp->view); | 475 | raw3270_del_view(&fp->view); |
469 | return rc; | 476 | goto out; |
470 | } | 477 | } |
471 | filp->private_data = fp; | 478 | filp->private_data = fp; |
479 | out: | ||
480 | unlock_kernel(); | ||
472 | return 0; | 481 | return 0; |
473 | } | 482 | } |
474 | 483 | ||
diff --git a/drivers/s390/char/monreader.c b/drivers/s390/char/monreader.c index f0e4c96afbf8..35fd8dfcaaa6 100644 --- a/drivers/s390/char/monreader.c +++ b/drivers/s390/char/monreader.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/module.h> | 10 | #include <linux/module.h> |
11 | #include <linux/moduleparam.h> | 11 | #include <linux/moduleparam.h> |
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/smp_lock.h> | ||
13 | #include <linux/errno.h> | 14 | #include <linux/errno.h> |
14 | #include <linux/types.h> | 15 | #include <linux/types.h> |
15 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
@@ -291,6 +292,7 @@ static int mon_open(struct inode *inode, struct file *filp) | |||
291 | /* | 292 | /* |
292 | * only one user allowed | 293 | * only one user allowed |
293 | */ | 294 | */ |
295 | lock_kernel(); | ||
294 | rc = -EBUSY; | 296 | rc = -EBUSY; |
295 | if (test_and_set_bit(MON_IN_USE, &mon_in_use)) | 297 | if (test_and_set_bit(MON_IN_USE, &mon_in_use)) |
296 | goto out; | 298 | goto out; |
@@ -327,6 +329,7 @@ static int mon_open(struct inode *inode, struct file *filp) | |||
327 | goto out_path; | 329 | goto out_path; |
328 | } | 330 | } |
329 | filp->private_data = monpriv; | 331 | filp->private_data = monpriv; |
332 | unlock_kernel(); | ||
330 | return nonseekable_open(inode, filp); | 333 | return nonseekable_open(inode, filp); |
331 | 334 | ||
332 | out_path: | 335 | out_path: |
@@ -336,6 +339,7 @@ out_priv: | |||
336 | out_use: | 339 | out_use: |
337 | clear_bit(MON_IN_USE, &mon_in_use); | 340 | clear_bit(MON_IN_USE, &mon_in_use); |
338 | out: | 341 | out: |
342 | unlock_kernel(); | ||
339 | return rc; | 343 | return rc; |
340 | } | 344 | } |
341 | 345 | ||
diff --git a/drivers/s390/char/monwriter.c b/drivers/s390/char/monwriter.c index a86c0534cd49..4d71aa8c1a79 100644 --- a/drivers/s390/char/monwriter.c +++ b/drivers/s390/char/monwriter.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/moduleparam.h> | 12 | #include <linux/moduleparam.h> |
13 | #include <linux/init.h> | 13 | #include <linux/init.h> |
14 | #include <linux/errno.h> | 14 | #include <linux/errno.h> |
15 | #include <linux/smp_lock.h> | ||
15 | #include <linux/types.h> | 16 | #include <linux/types.h> |
16 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
17 | #include <linux/miscdevice.h> | 18 | #include <linux/miscdevice.h> |
@@ -179,10 +180,12 @@ static int monwrite_open(struct inode *inode, struct file *filp) | |||
179 | monpriv = kzalloc(sizeof(struct mon_private), GFP_KERNEL); | 180 | monpriv = kzalloc(sizeof(struct mon_private), GFP_KERNEL); |
180 | if (!monpriv) | 181 | if (!monpriv) |
181 | return -ENOMEM; | 182 | return -ENOMEM; |
183 | lock_kernel(); | ||
182 | INIT_LIST_HEAD(&monpriv->list); | 184 | INIT_LIST_HEAD(&monpriv->list); |
183 | monpriv->hdr_to_read = sizeof(monpriv->hdr); | 185 | monpriv->hdr_to_read = sizeof(monpriv->hdr); |
184 | mutex_init(&monpriv->thread_mutex); | 186 | mutex_init(&monpriv->thread_mutex); |
185 | filp->private_data = monpriv; | 187 | filp->private_data = monpriv; |
188 | unlock_kernel(); | ||
186 | return nonseekable_open(inode, filp); | 189 | return nonseekable_open(inode, filp); |
187 | } | 190 | } |
188 | 191 | ||
diff --git a/drivers/s390/char/tape_char.c b/drivers/s390/char/tape_char.c index ebe84067bae9..687720b552d1 100644 --- a/drivers/s390/char/tape_char.c +++ b/drivers/s390/char/tape_char.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/types.h> | 14 | #include <linux/types.h> |
15 | #include <linux/proc_fs.h> | 15 | #include <linux/proc_fs.h> |
16 | #include <linux/mtio.h> | 16 | #include <linux/mtio.h> |
17 | #include <linux/smp_lock.h> | ||
17 | 18 | ||
18 | #include <asm/uaccess.h> | 19 | #include <asm/uaccess.h> |
19 | 20 | ||
@@ -289,21 +290,26 @@ tapechar_open (struct inode *inode, struct file *filp) | |||
289 | if (imajor(filp->f_path.dentry->d_inode) != tapechar_major) | 290 | if (imajor(filp->f_path.dentry->d_inode) != tapechar_major) |
290 | return -ENODEV; | 291 | return -ENODEV; |
291 | 292 | ||
293 | lock_kernel(); | ||
292 | minor = iminor(filp->f_path.dentry->d_inode); | 294 | minor = iminor(filp->f_path.dentry->d_inode); |
293 | device = tape_get_device(minor / TAPE_MINORS_PER_DEV); | 295 | device = tape_get_device(minor / TAPE_MINORS_PER_DEV); |
294 | if (IS_ERR(device)) { | 296 | if (IS_ERR(device)) { |
295 | DBF_EVENT(3, "TCHAR:open: tape_get_device() failed\n"); | 297 | DBF_EVENT(3, "TCHAR:open: tape_get_device() failed\n"); |
296 | return PTR_ERR(device); | 298 | rc = PTR_ERR(device); |
299 | goto out; | ||
297 | } | 300 | } |
298 | 301 | ||
299 | 302 | ||
300 | rc = tape_open(device); | 303 | rc = tape_open(device); |
301 | if (rc == 0) { | 304 | if (rc == 0) { |
302 | filp->private_data = device; | 305 | filp->private_data = device; |
303 | return nonseekable_open(inode, filp); | 306 | rc = nonseekable_open(inode, filp); |
304 | } | 307 | } |
305 | tape_put_device(device); | 308 | else |
309 | tape_put_device(device); | ||
306 | 310 | ||
311 | out: | ||
312 | unlock_kernel(); | ||
307 | return rc; | 313 | return rc; |
308 | } | 314 | } |
309 | 315 | ||
diff --git a/drivers/s390/char/vmcp.c b/drivers/s390/char/vmcp.c index 401ea84b3059..09e7d9bf438b 100644 --- a/drivers/s390/char/vmcp.c +++ b/drivers/s390/char/vmcp.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
17 | #include <linux/miscdevice.h> | 17 | #include <linux/miscdevice.h> |
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/smp_lock.h> | ||
19 | #include <asm/cpcmd.h> | 20 | #include <asm/cpcmd.h> |
20 | #include <asm/debug.h> | 21 | #include <asm/debug.h> |
21 | #include <asm/uaccess.h> | 22 | #include <asm/uaccess.h> |
@@ -39,11 +40,14 @@ static int vmcp_open(struct inode *inode, struct file *file) | |||
39 | session = kmalloc(sizeof(*session), GFP_KERNEL); | 40 | session = kmalloc(sizeof(*session), GFP_KERNEL); |
40 | if (!session) | 41 | if (!session) |
41 | return -ENOMEM; | 42 | return -ENOMEM; |
43 | |||
44 | lock_kernel(); | ||
42 | session->bufsize = PAGE_SIZE; | 45 | session->bufsize = PAGE_SIZE; |
43 | session->response = NULL; | 46 | session->response = NULL; |
44 | session->resp_size = 0; | 47 | session->resp_size = 0; |
45 | mutex_init(&session->mutex); | 48 | mutex_init(&session->mutex); |
46 | file->private_data = session; | 49 | file->private_data = session; |
50 | unlock_kernel(); | ||
47 | return nonseekable_open(inode, file); | 51 | return nonseekable_open(inode, file); |
48 | } | 52 | } |
49 | 53 | ||
diff --git a/drivers/s390/char/vmlogrdr.c b/drivers/s390/char/vmlogrdr.c index a246bc73ae64..c31faefa2b3b 100644 --- a/drivers/s390/char/vmlogrdr.c +++ b/drivers/s390/char/vmlogrdr.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/kmod.h> | 25 | #include <linux/kmod.h> |
26 | #include <linux/cdev.h> | 26 | #include <linux/cdev.h> |
27 | #include <linux/device.h> | 27 | #include <linux/device.h> |
28 | #include <linux/smp_lock.h> | ||
28 | #include <linux/string.h> | 29 | #include <linux/string.h> |
29 | 30 | ||
30 | 31 | ||
@@ -310,9 +311,11 @@ static int vmlogrdr_open (struct inode *inode, struct file *filp) | |||
310 | return -ENOSYS; | 311 | return -ENOSYS; |
311 | 312 | ||
312 | /* Besure this device hasn't already been opened */ | 313 | /* Besure this device hasn't already been opened */ |
314 | lock_kernel(); | ||
313 | spin_lock_bh(&logptr->priv_lock); | 315 | spin_lock_bh(&logptr->priv_lock); |
314 | if (logptr->dev_in_use) { | 316 | if (logptr->dev_in_use) { |
315 | spin_unlock_bh(&logptr->priv_lock); | 317 | spin_unlock_bh(&logptr->priv_lock); |
318 | unlock_kernel(); | ||
316 | return -EBUSY; | 319 | return -EBUSY; |
317 | } | 320 | } |
318 | logptr->dev_in_use = 1; | 321 | logptr->dev_in_use = 1; |
@@ -356,7 +359,9 @@ static int vmlogrdr_open (struct inode *inode, struct file *filp) | |||
356 | || (logptr->iucv_path_severed)); | 359 | || (logptr->iucv_path_severed)); |
357 | if (logptr->iucv_path_severed) | 360 | if (logptr->iucv_path_severed) |
358 | goto out_record; | 361 | goto out_record; |
359 | return nonseekable_open(inode, filp); | 362 | ret = nonseekable_open(inode, filp); |
363 | unlock_kernel(); | ||
364 | return ret; | ||
360 | 365 | ||
361 | out_record: | 366 | out_record: |
362 | if (logptr->autorecording) | 367 | if (logptr->autorecording) |
@@ -366,6 +371,7 @@ out_path: | |||
366 | logptr->path = NULL; | 371 | logptr->path = NULL; |
367 | out_dev: | 372 | out_dev: |
368 | logptr->dev_in_use = 0; | 373 | logptr->dev_in_use = 0; |
374 | unlock_kernel(); | ||
369 | return -EIO; | 375 | return -EIO; |
370 | } | 376 | } |
371 | 377 | ||
diff --git a/drivers/s390/char/vmur.c b/drivers/s390/char/vmur.c index 49cba9effe89..0a9f1cccbe58 100644 --- a/drivers/s390/char/vmur.c +++ b/drivers/s390/char/vmur.c | |||
@@ -9,6 +9,7 @@ | |||
9 | */ | 9 | */ |
10 | 10 | ||
11 | #include <linux/cdev.h> | 11 | #include <linux/cdev.h> |
12 | #include <linux/smp_lock.h> | ||
12 | 13 | ||
13 | #include <asm/uaccess.h> | 14 | #include <asm/uaccess.h> |
14 | #include <asm/cio.h> | 15 | #include <asm/cio.h> |
@@ -669,7 +670,7 @@ static int ur_open(struct inode *inode, struct file *file) | |||
669 | 670 | ||
670 | if (accmode == O_RDWR) | 671 | if (accmode == O_RDWR) |
671 | return -EACCES; | 672 | return -EACCES; |
672 | 673 | lock_kernel(); | |
673 | /* | 674 | /* |
674 | * We treat the minor number as the devno of the ur device | 675 | * We treat the minor number as the devno of the ur device |
675 | * to find in the driver tree. | 676 | * to find in the driver tree. |
@@ -677,8 +678,10 @@ static int ur_open(struct inode *inode, struct file *file) | |||
677 | devno = MINOR(file->f_dentry->d_inode->i_rdev); | 678 | devno = MINOR(file->f_dentry->d_inode->i_rdev); |
678 | 679 | ||
679 | urd = urdev_get_from_devno(devno); | 680 | urd = urdev_get_from_devno(devno); |
680 | if (!urd) | 681 | if (!urd) { |
681 | return -ENXIO; | 682 | rc = -ENXIO; |
683 | goto out; | ||
684 | } | ||
682 | 685 | ||
683 | spin_lock(&urd->open_lock); | 686 | spin_lock(&urd->open_lock); |
684 | while (urd->open_flag) { | 687 | while (urd->open_flag) { |
@@ -721,6 +724,7 @@ static int ur_open(struct inode *inode, struct file *file) | |||
721 | goto fail_urfile_free; | 724 | goto fail_urfile_free; |
722 | urf->file_reclen = rc; | 725 | urf->file_reclen = rc; |
723 | file->private_data = urf; | 726 | file->private_data = urf; |
727 | unlock_kernel(); | ||
724 | return 0; | 728 | return 0; |
725 | 729 | ||
726 | fail_urfile_free: | 730 | fail_urfile_free: |
@@ -731,6 +735,8 @@ fail_unlock: | |||
731 | spin_unlock(&urd->open_lock); | 735 | spin_unlock(&urd->open_lock); |
732 | fail_put: | 736 | fail_put: |
733 | urdev_put(urd); | 737 | urdev_put(urd); |
738 | out: | ||
739 | unlock_kernel(); | ||
734 | return rc; | 740 | return rc; |
735 | } | 741 | } |
736 | 742 | ||
diff --git a/drivers/s390/char/vmwatchdog.c b/drivers/s390/char/vmwatchdog.c index 56b3eab019cb..21a2a829bf4e 100644 --- a/drivers/s390/char/vmwatchdog.c +++ b/drivers/s390/char/vmwatchdog.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
14 | #include <linux/moduleparam.h> | 14 | #include <linux/moduleparam.h> |
15 | #include <linux/watchdog.h> | 15 | #include <linux/watchdog.h> |
16 | #include <linux/smp_lock.h> | ||
16 | 17 | ||
17 | #include <asm/ebcdic.h> | 18 | #include <asm/ebcdic.h> |
18 | #include <asm/io.h> | 19 | #include <asm/io.h> |
@@ -121,11 +122,15 @@ static int __init vmwdt_probe(void) | |||
121 | static int vmwdt_open(struct inode *i, struct file *f) | 122 | static int vmwdt_open(struct inode *i, struct file *f) |
122 | { | 123 | { |
123 | int ret; | 124 | int ret; |
124 | if (test_and_set_bit(0, &vmwdt_is_open)) | 125 | lock_kernel(); |
126 | if (test_and_set_bit(0, &vmwdt_is_open)) { | ||
127 | unlock_kernel(); | ||
125 | return -EBUSY; | 128 | return -EBUSY; |
129 | } | ||
126 | ret = vmwdt_keepalive(); | 130 | ret = vmwdt_keepalive(); |
127 | if (ret) | 131 | if (ret) |
128 | clear_bit(0, &vmwdt_is_open); | 132 | clear_bit(0, &vmwdt_is_open); |
133 | unlock_kernel(); | ||
129 | return ret ? ret : nonseekable_open(i, f); | 134 | return ret ? ret : nonseekable_open(i, f); |
130 | } | 135 | } |
131 | 136 | ||
diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c index 8a4964f3584b..cb22b97944b8 100644 --- a/drivers/s390/crypto/zcrypt_api.c +++ b/drivers/s390/crypto/zcrypt_api.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/fs.h> | 34 | #include <linux/fs.h> |
35 | #include <linux/proc_fs.h> | 35 | #include <linux/proc_fs.h> |
36 | #include <linux/compat.h> | 36 | #include <linux/compat.h> |
37 | #include <linux/smp_lock.h> | ||
37 | #include <asm/atomic.h> | 38 | #include <asm/atomic.h> |
38 | #include <asm/uaccess.h> | 39 | #include <asm/uaccess.h> |
39 | #include <linux/hw_random.h> | 40 | #include <linux/hw_random.h> |
@@ -300,7 +301,9 @@ static ssize_t zcrypt_write(struct file *filp, const char __user *buf, | |||
300 | */ | 301 | */ |
301 | static int zcrypt_open(struct inode *inode, struct file *filp) | 302 | static int zcrypt_open(struct inode *inode, struct file *filp) |
302 | { | 303 | { |
304 | lock_kernel(); | ||
303 | atomic_inc(&zcrypt_open_count); | 305 | atomic_inc(&zcrypt_open_count); |
306 | unlock_kernel(); | ||
304 | return 0; | 307 | return 0; |
305 | } | 308 | } |
306 | 309 | ||
diff --git a/drivers/sbus/char/bpp.c b/drivers/sbus/char/bpp.c index 03c966059471..bba21e053a1b 100644 --- a/drivers/sbus/char/bpp.c +++ b/drivers/sbus/char/bpp.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/timer.h> | 19 | #include <linux/timer.h> |
20 | #include <linux/ioport.h> | 20 | #include <linux/ioport.h> |
21 | #include <linux/major.h> | 21 | #include <linux/major.h> |
22 | #include <linux/smp_lock.h> | ||
22 | 23 | ||
23 | #include <asm/uaccess.h> | 24 | #include <asm/uaccess.h> |
24 | #include <asm/io.h> | 25 | #include <asm/io.h> |
@@ -429,6 +430,7 @@ static int bpp_open(struct inode *inode, struct file *f) | |||
429 | unsigned minor = iminor(inode); | 430 | unsigned minor = iminor(inode); |
430 | int ret; | 431 | int ret; |
431 | 432 | ||
433 | lock_kernel(); | ||
432 | spin_lock(&bpp_open_lock); | 434 | spin_lock(&bpp_open_lock); |
433 | ret = 0; | 435 | ret = 0; |
434 | if (minor >= BPP_NO) { | 436 | if (minor >= BPP_NO) { |
@@ -444,6 +446,7 @@ static int bpp_open(struct inode *inode, struct file *f) | |||
444 | } | 446 | } |
445 | } | 447 | } |
446 | spin_unlock(&bpp_open_lock); | 448 | spin_unlock(&bpp_open_lock); |
449 | unlock_kernel(); | ||
447 | 450 | ||
448 | return ret; | 451 | return ret; |
449 | } | 452 | } |
diff --git a/drivers/sbus/char/cpwatchdog.c b/drivers/sbus/char/cpwatchdog.c index 235703414370..23abfdfb44f1 100644 --- a/drivers/sbus/char/cpwatchdog.c +++ b/drivers/sbus/char/cpwatchdog.c | |||
@@ -279,6 +279,7 @@ static inline int wd_opt_timeout(void) | |||
279 | 279 | ||
280 | static int wd_open(struct inode *inode, struct file *f) | 280 | static int wd_open(struct inode *inode, struct file *f) |
281 | { | 281 | { |
282 | lock_kernel(); | ||
282 | switch(iminor(inode)) | 283 | switch(iminor(inode)) |
283 | { | 284 | { |
284 | case WD0_MINOR: | 285 | case WD0_MINOR: |
@@ -291,6 +292,7 @@ static int wd_open(struct inode *inode, struct file *f) | |||
291 | f->private_data = &wd_dev.watchdog[WD2_ID]; | 292 | f->private_data = &wd_dev.watchdog[WD2_ID]; |
292 | break; | 293 | break; |
293 | default: | 294 | default: |
295 | unlock_kernel(); | ||
294 | return(-ENODEV); | 296 | return(-ENODEV); |
295 | } | 297 | } |
296 | 298 | ||
@@ -304,11 +306,13 @@ static int wd_open(struct inode *inode, struct file *f) | |||
304 | (void *)wd_dev.regs)) { | 306 | (void *)wd_dev.regs)) { |
305 | printk("%s: Cannot register IRQ %d\n", | 307 | printk("%s: Cannot register IRQ %d\n", |
306 | WD_OBPNAME, wd_dev.irq); | 308 | WD_OBPNAME, wd_dev.irq); |
309 | unlock_kernel(); | ||
307 | return(-EBUSY); | 310 | return(-EBUSY); |
308 | } | 311 | } |
309 | wd_dev.initialized = 1; | 312 | wd_dev.initialized = 1; |
310 | } | 313 | } |
311 | 314 | ||
315 | unlock_kernel(); | ||
312 | return(nonseekable_open(inode, f)); | 316 | return(nonseekable_open(inode, f)); |
313 | } | 317 | } |
314 | 318 | ||
diff --git a/drivers/sbus/char/display7seg.c b/drivers/sbus/char/display7seg.c index 3279a1b6501d..d8f5c0ca236d 100644 --- a/drivers/sbus/char/display7seg.c +++ b/drivers/sbus/char/display7seg.c | |||
@@ -94,6 +94,7 @@ static int d7s_open(struct inode *inode, struct file *f) | |||
94 | { | 94 | { |
95 | if (D7S_MINOR != iminor(inode)) | 95 | if (D7S_MINOR != iminor(inode)) |
96 | return -ENODEV; | 96 | return -ENODEV; |
97 | cycle_kernel_lock(); | ||
97 | atomic_inc(&d7s_users); | 98 | atomic_inc(&d7s_users); |
98 | return 0; | 99 | return 0; |
99 | } | 100 | } |
diff --git a/drivers/sbus/char/envctrl.c b/drivers/sbus/char/envctrl.c index dadabef116b6..a408402426f8 100644 --- a/drivers/sbus/char/envctrl.c +++ b/drivers/sbus/char/envctrl.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/miscdevice.h> | 27 | #include <linux/miscdevice.h> |
28 | #include <linux/kmod.h> | 28 | #include <linux/kmod.h> |
29 | #include <linux/reboot.h> | 29 | #include <linux/reboot.h> |
30 | #include <linux/smp_lock.h> | ||
30 | 31 | ||
31 | #include <asm/ebus.h> | 32 | #include <asm/ebus.h> |
32 | #include <asm/uaccess.h> | 33 | #include <asm/uaccess.h> |
@@ -694,6 +695,7 @@ envctrl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
694 | static int | 695 | static int |
695 | envctrl_open(struct inode *inode, struct file *file) | 696 | envctrl_open(struct inode *inode, struct file *file) |
696 | { | 697 | { |
698 | cycle_kernel_lock(); | ||
697 | file->private_data = NULL; | 699 | file->private_data = NULL; |
698 | return 0; | 700 | return 0; |
699 | } | 701 | } |
diff --git a/drivers/sbus/char/flash.c b/drivers/sbus/char/flash.c index 44e039865aa9..7d95e151513a 100644 --- a/drivers/sbus/char/flash.c +++ b/drivers/sbus/char/flash.c | |||
@@ -127,9 +127,13 @@ flash_read(struct file * file, char __user * buf, | |||
127 | static int | 127 | static int |
128 | flash_open(struct inode *inode, struct file *file) | 128 | flash_open(struct inode *inode, struct file *file) |
129 | { | 129 | { |
130 | if (test_and_set_bit(0, (void *)&flash.busy) != 0) | 130 | lock_kernel(); |
131 | if (test_and_set_bit(0, (void *)&flash.busy) != 0) { | ||
132 | unlock_kernel(); | ||
131 | return -EBUSY; | 133 | return -EBUSY; |
134 | } | ||
132 | 135 | ||
136 | unlock_kernel(); | ||
133 | return 0; | 137 | return 0; |
134 | } | 138 | } |
135 | 139 | ||
diff --git a/drivers/sbus/char/jsflash.c b/drivers/sbus/char/jsflash.c index 4b7079fdc10c..2bec9ccc0293 100644 --- a/drivers/sbus/char/jsflash.c +++ b/drivers/sbus/char/jsflash.c | |||
@@ -27,6 +27,7 @@ | |||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <linux/module.h> | 29 | #include <linux/module.h> |
30 | #include <linux/smp_lock.h> | ||
30 | #include <linux/types.h> | 31 | #include <linux/types.h> |
31 | #include <linux/errno.h> | 32 | #include <linux/errno.h> |
32 | #include <linux/miscdevice.h> | 33 | #include <linux/miscdevice.h> |
@@ -417,11 +418,17 @@ static int jsf_mmap(struct file * file, struct vm_area_struct * vma) | |||
417 | 418 | ||
418 | static int jsf_open(struct inode * inode, struct file * filp) | 419 | static int jsf_open(struct inode * inode, struct file * filp) |
419 | { | 420 | { |
420 | 421 | lock_kernel(); | |
421 | if (jsf0.base == 0) return -ENXIO; | 422 | if (jsf0.base == 0) { |
422 | if (test_and_set_bit(0, (void *)&jsf0.busy) != 0) | 423 | unlock_kernel(); |
424 | return -ENXIO; | ||
425 | } | ||
426 | if (test_and_set_bit(0, (void *)&jsf0.busy) != 0) { | ||
427 | unlock_kernel(); | ||
423 | return -EBUSY; | 428 | return -EBUSY; |
429 | } | ||
424 | 430 | ||
431 | unlock_kernel(); | ||
425 | return 0; /* XXX What security? */ | 432 | return 0; /* XXX What security? */ |
426 | } | 433 | } |
427 | 434 | ||
diff --git a/drivers/sbus/char/openprom.c b/drivers/sbus/char/openprom.c index fbfeb89a6f32..29dc735e1a20 100644 --- a/drivers/sbus/char/openprom.c +++ b/drivers/sbus/char/openprom.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/kernel.h> | 33 | #include <linux/kernel.h> |
34 | #include <linux/errno.h> | 34 | #include <linux/errno.h> |
35 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
36 | #include <linux/smp_lock.h> | ||
36 | #include <linux/string.h> | 37 | #include <linux/string.h> |
37 | #include <linux/miscdevice.h> | 38 | #include <linux/miscdevice.h> |
38 | #include <linux/init.h> | 39 | #include <linux/init.h> |
@@ -689,9 +690,11 @@ static int openprom_open(struct inode * inode, struct file * file) | |||
689 | if (!data) | 690 | if (!data) |
690 | return -ENOMEM; | 691 | return -ENOMEM; |
691 | 692 | ||
693 | lock_kernel(); | ||
692 | data->current_node = of_find_node_by_path("/"); | 694 | data->current_node = of_find_node_by_path("/"); |
693 | data->lastnode = data->current_node; | 695 | data->lastnode = data->current_node; |
694 | file->private_data = (void *) data; | 696 | file->private_data = (void *) data; |
697 | unlock_kernel(); | ||
695 | 698 | ||
696 | return 0; | 699 | return 0; |
697 | } | 700 | } |
diff --git a/drivers/sbus/char/riowatchdog.c b/drivers/sbus/char/riowatchdog.c index a2fc6b8c1334..88c0fc6395e1 100644 --- a/drivers/sbus/char/riowatchdog.c +++ b/drivers/sbus/char/riowatchdog.c | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <linux/errno.h> | 11 | #include <linux/errno.h> |
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/miscdevice.h> | 13 | #include <linux/miscdevice.h> |
14 | #include <linux/smp_lock.h> | ||
14 | 15 | ||
15 | #include <asm/io.h> | 16 | #include <asm/io.h> |
16 | #include <asm/ebus.h> | 17 | #include <asm/ebus.h> |
@@ -116,6 +117,7 @@ static void riowd_starttimer(void) | |||
116 | 117 | ||
117 | static int riowd_open(struct inode *inode, struct file *filp) | 118 | static int riowd_open(struct inode *inode, struct file *filp) |
118 | { | 119 | { |
120 | cycle_kernel_lock(); | ||
119 | nonseekable_open(inode, filp); | 121 | nonseekable_open(inode, filp); |
120 | return 0; | 122 | return 0; |
121 | } | 123 | } |
diff --git a/drivers/sbus/char/rtc.c b/drivers/sbus/char/rtc.c index 18d18f1a114e..b0429917154d 100644 --- a/drivers/sbus/char/rtc.c +++ b/drivers/sbus/char/rtc.c | |||
@@ -12,6 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include <linux/smp_lock.h> | ||
15 | #include <linux/types.h> | 16 | #include <linux/types.h> |
16 | #include <linux/errno.h> | 17 | #include <linux/errno.h> |
17 | #include <linux/miscdevice.h> | 18 | #include <linux/miscdevice.h> |
@@ -213,6 +214,7 @@ static int rtc_open(struct inode *inode, struct file *file) | |||
213 | { | 214 | { |
214 | int ret; | 215 | int ret; |
215 | 216 | ||
217 | lock_kernel(); | ||
216 | spin_lock_irq(&mostek_lock); | 218 | spin_lock_irq(&mostek_lock); |
217 | if (rtc_busy) { | 219 | if (rtc_busy) { |
218 | ret = -EBUSY; | 220 | ret = -EBUSY; |
@@ -221,6 +223,7 @@ static int rtc_open(struct inode *inode, struct file *file) | |||
221 | ret = 0; | 223 | ret = 0; |
222 | } | 224 | } |
223 | spin_unlock_irq(&mostek_lock); | 225 | spin_unlock_irq(&mostek_lock); |
226 | unlock_kernel(); | ||
224 | 227 | ||
225 | return ret; | 228 | return ret; |
226 | } | 229 | } |
diff --git a/drivers/sbus/char/uctrl.c b/drivers/sbus/char/uctrl.c index 383f32c1d347..513ba61ae966 100644 --- a/drivers/sbus/char/uctrl.c +++ b/drivers/sbus/char/uctrl.c | |||
@@ -9,6 +9,7 @@ | |||
9 | #include <linux/delay.h> | 9 | #include <linux/delay.h> |
10 | #include <linux/interrupt.h> | 10 | #include <linux/interrupt.h> |
11 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
12 | #include <linux/smp_lock.h> | ||
12 | #include <linux/ioport.h> | 13 | #include <linux/ioport.h> |
13 | #include <linux/init.h> | 14 | #include <linux/init.h> |
14 | #include <linux/miscdevice.h> | 15 | #include <linux/miscdevice.h> |
@@ -211,8 +212,10 @@ uctrl_ioctl(struct inode *inode, struct file *file, | |||
211 | static int | 212 | static int |
212 | uctrl_open(struct inode *inode, struct file *file) | 213 | uctrl_open(struct inode *inode, struct file *file) |
213 | { | 214 | { |
215 | lock_kernel(); | ||
214 | uctrl_get_event_status(); | 216 | uctrl_get_event_status(); |
215 | uctrl_get_external_status(); | 217 | uctrl_get_external_status(); |
218 | unlock_kernel(); | ||
216 | return 0; | 219 | return 0; |
217 | } | 220 | } |
218 | 221 | ||
diff --git a/drivers/sbus/char/vfc_dev.c b/drivers/sbus/char/vfc_dev.c index d4f8fcded51d..1f6cb8ae2784 100644 --- a/drivers/sbus/char/vfc_dev.c +++ b/drivers/sbus/char/vfc_dev.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/spinlock.h> | 24 | #include <linux/spinlock.h> |
25 | #include <linux/mutex.h> | 25 | #include <linux/mutex.h> |
26 | #include <linux/mm.h> | 26 | #include <linux/mm.h> |
27 | #include <linux/smp_lock.h> | ||
27 | 28 | ||
28 | #include <asm/openprom.h> | 29 | #include <asm/openprom.h> |
29 | #include <asm/oplib.h> | 30 | #include <asm/oplib.h> |
@@ -178,14 +179,17 @@ static int vfc_open(struct inode *inode, struct file *file) | |||
178 | { | 179 | { |
179 | struct vfc_dev *dev; | 180 | struct vfc_dev *dev; |
180 | 181 | ||
182 | lock_kernel(); | ||
181 | spin_lock(&vfc_dev_lock); | 183 | spin_lock(&vfc_dev_lock); |
182 | dev = vfc_get_dev_ptr(iminor(inode)); | 184 | dev = vfc_get_dev_ptr(iminor(inode)); |
183 | if (dev == NULL) { | 185 | if (dev == NULL) { |
184 | spin_unlock(&vfc_dev_lock); | 186 | spin_unlock(&vfc_dev_lock); |
187 | unlock_kernel(); | ||
185 | return -ENODEV; | 188 | return -ENODEV; |
186 | } | 189 | } |
187 | if (dev->busy) { | 190 | if (dev->busy) { |
188 | spin_unlock(&vfc_dev_lock); | 191 | spin_unlock(&vfc_dev_lock); |
192 | unlock_kernel(); | ||
189 | return -EBUSY; | 193 | return -EBUSY; |
190 | } | 194 | } |
191 | 195 | ||
@@ -202,6 +206,7 @@ static int vfc_open(struct inode *inode, struct file *file) | |||
202 | vfc_captstat_reset(dev); | 206 | vfc_captstat_reset(dev); |
203 | 207 | ||
204 | vfc_unlock_device(dev); | 208 | vfc_unlock_device(dev); |
209 | unlock_kernel(); | ||
205 | return 0; | 210 | return 0; |
206 | } | 211 | } |
207 | 212 | ||
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index 867f6fd5c2c0..7045511f9ad2 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c | |||
@@ -84,6 +84,7 @@ | |||
84 | #include <linux/pci.h> | 84 | #include <linux/pci.h> |
85 | #include <linux/time.h> | 85 | #include <linux/time.h> |
86 | #include <linux/mutex.h> | 86 | #include <linux/mutex.h> |
87 | #include <linux/smp_lock.h> | ||
87 | #include <asm/io.h> | 88 | #include <asm/io.h> |
88 | #include <asm/irq.h> | 89 | #include <asm/irq.h> |
89 | #include <asm/uaccess.h> | 90 | #include <asm/uaccess.h> |
@@ -862,11 +863,13 @@ out: | |||
862 | } /* End twa_chrdev_ioctl() */ | 863 | } /* End twa_chrdev_ioctl() */ |
863 | 864 | ||
864 | /* This function handles open for the character device */ | 865 | /* This function handles open for the character device */ |
866 | /* NOTE that this function will race with remove. */ | ||
865 | static int twa_chrdev_open(struct inode *inode, struct file *file) | 867 | static int twa_chrdev_open(struct inode *inode, struct file *file) |
866 | { | 868 | { |
867 | unsigned int minor_number; | 869 | unsigned int minor_number; |
868 | int retval = TW_IOCTL_ERROR_OS_ENODEV; | 870 | int retval = TW_IOCTL_ERROR_OS_ENODEV; |
869 | 871 | ||
872 | cycle_kernel_lock(); | ||
870 | minor_number = iminor(inode); | 873 | minor_number = iminor(inode); |
871 | if (minor_number >= twa_device_extension_count) | 874 | if (minor_number >= twa_device_extension_count) |
872 | goto out; | 875 | goto out; |
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index 8c22329aa85e..a0537f09aa21 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c | |||
@@ -198,6 +198,7 @@ | |||
198 | 198 | ||
199 | #include <linux/module.h> | 199 | #include <linux/module.h> |
200 | #include <linux/reboot.h> | 200 | #include <linux/reboot.h> |
201 | #include <linux/smp_lock.h> | ||
201 | #include <linux/spinlock.h> | 202 | #include <linux/spinlock.h> |
202 | #include <linux/interrupt.h> | 203 | #include <linux/interrupt.h> |
203 | #include <linux/moduleparam.h> | 204 | #include <linux/moduleparam.h> |
@@ -1027,10 +1028,12 @@ out: | |||
1027 | } /* End tw_chrdev_ioctl() */ | 1028 | } /* End tw_chrdev_ioctl() */ |
1028 | 1029 | ||
1029 | /* This function handles open for the character device */ | 1030 | /* This function handles open for the character device */ |
1031 | /* NOTE that this function races with remove. */ | ||
1030 | static int tw_chrdev_open(struct inode *inode, struct file *file) | 1032 | static int tw_chrdev_open(struct inode *inode, struct file *file) |
1031 | { | 1033 | { |
1032 | unsigned int minor_number; | 1034 | unsigned int minor_number; |
1033 | 1035 | ||
1036 | cycle_kernel_lock(); | ||
1034 | dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_open()\n"); | 1037 | dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_open()\n"); |
1035 | 1038 | ||
1036 | minor_number = iminor(inode); | 1039 | minor_number = iminor(inode); |
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index 1f7c83607f84..68c140e82673 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/moduleparam.h> | 38 | #include <linux/moduleparam.h> |
39 | #include <linux/pci.h> | 39 | #include <linux/pci.h> |
40 | #include <linux/slab.h> | 40 | #include <linux/slab.h> |
41 | #include <linux/smp_lock.h> | ||
41 | #include <linux/spinlock.h> | 42 | #include <linux/spinlock.h> |
42 | #include <linux/syscalls.h> | 43 | #include <linux/syscalls.h> |
43 | #include <linux/delay.h> | 44 | #include <linux/delay.h> |
@@ -667,6 +668,7 @@ static int aac_cfg_open(struct inode *inode, struct file *file) | |||
667 | unsigned minor_number = iminor(inode); | 668 | unsigned minor_number = iminor(inode); |
668 | int err = -ENODEV; | 669 | int err = -ENODEV; |
669 | 670 | ||
671 | lock_kernel(); /* BKL pushdown: nothing else protects this list */ | ||
670 | list_for_each_entry(aac, &aac_devices, entry) { | 672 | list_for_each_entry(aac, &aac_devices, entry) { |
671 | if (aac->id == minor_number) { | 673 | if (aac->id == minor_number) { |
672 | file->private_data = aac; | 674 | file->private_data = aac; |
@@ -674,6 +676,7 @@ static int aac_cfg_open(struct inode *inode, struct file *file) | |||
674 | break; | 676 | break; |
675 | } | 677 | } |
676 | } | 678 | } |
679 | unlock_kernel(); | ||
677 | 680 | ||
678 | return err; | 681 | return err; |
679 | } | 682 | } |
diff --git a/drivers/scsi/ch.c b/drivers/scsi/ch.c index c4b938bc30d3..aa2011b64683 100644 --- a/drivers/scsi/ch.c +++ b/drivers/scsi/ch.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/chio.h> /* here are all the ioctls */ | 22 | #include <linux/chio.h> /* here are all the ioctls */ |
23 | #include <linux/mutex.h> | 23 | #include <linux/mutex.h> |
24 | #include <linux/idr.h> | 24 | #include <linux/idr.h> |
25 | #include <linux/smp_lock.h> | ||
25 | 26 | ||
26 | #include <scsi/scsi.h> | 27 | #include <scsi/scsi.h> |
27 | #include <scsi/scsi_cmnd.h> | 28 | #include <scsi/scsi_cmnd.h> |
@@ -571,16 +572,19 @@ ch_open(struct inode *inode, struct file *file) | |||
571 | scsi_changer *ch; | 572 | scsi_changer *ch; |
572 | int minor = iminor(inode); | 573 | int minor = iminor(inode); |
573 | 574 | ||
575 | lock_kernel(); | ||
574 | spin_lock(&ch_index_lock); | 576 | spin_lock(&ch_index_lock); |
575 | ch = idr_find(&ch_index_idr, minor); | 577 | ch = idr_find(&ch_index_idr, minor); |
576 | 578 | ||
577 | if (NULL == ch || scsi_device_get(ch->device)) { | 579 | if (NULL == ch || scsi_device_get(ch->device)) { |
578 | spin_unlock(&ch_index_lock); | 580 | spin_unlock(&ch_index_lock); |
581 | unlock_kernel(); | ||
579 | return -ENXIO; | 582 | return -ENXIO; |
580 | } | 583 | } |
581 | spin_unlock(&ch_index_lock); | 584 | spin_unlock(&ch_index_lock); |
582 | 585 | ||
583 | file->private_data = ch; | 586 | file->private_data = ch; |
587 | unlock_kernel(); | ||
584 | return 0; | 588 | return 0; |
585 | } | 589 | } |
586 | 590 | ||
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c index 8508816f303d..2bc30e32b67a 100644 --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c | |||
@@ -49,6 +49,7 @@ MODULE_DESCRIPTION("Adaptec I2O RAID Driver"); | |||
49 | #include <linux/kernel.h> /* for printk */ | 49 | #include <linux/kernel.h> /* for printk */ |
50 | #include <linux/sched.h> | 50 | #include <linux/sched.h> |
51 | #include <linux/reboot.h> | 51 | #include <linux/reboot.h> |
52 | #include <linux/smp_lock.h> | ||
52 | #include <linux/spinlock.h> | 53 | #include <linux/spinlock.h> |
53 | #include <linux/dma-mapping.h> | 54 | #include <linux/dma-mapping.h> |
54 | 55 | ||
@@ -1727,10 +1728,12 @@ static int adpt_open(struct inode *inode, struct file *file) | |||
1727 | int minor; | 1728 | int minor; |
1728 | adpt_hba* pHba; | 1729 | adpt_hba* pHba; |
1729 | 1730 | ||
1731 | lock_kernel(); | ||
1730 | //TODO check for root access | 1732 | //TODO check for root access |
1731 | // | 1733 | // |
1732 | minor = iminor(inode); | 1734 | minor = iminor(inode); |
1733 | if (minor >= hba_count) { | 1735 | if (minor >= hba_count) { |
1736 | unlock_kernel(); | ||
1734 | return -ENXIO; | 1737 | return -ENXIO; |
1735 | } | 1738 | } |
1736 | mutex_lock(&adpt_configuration_lock); | 1739 | mutex_lock(&adpt_configuration_lock); |
@@ -1741,6 +1744,7 @@ static int adpt_open(struct inode *inode, struct file *file) | |||
1741 | } | 1744 | } |
1742 | if (pHba == NULL) { | 1745 | if (pHba == NULL) { |
1743 | mutex_unlock(&adpt_configuration_lock); | 1746 | mutex_unlock(&adpt_configuration_lock); |
1747 | unlock_kernel(); | ||
1744 | return -ENXIO; | 1748 | return -ENXIO; |
1745 | } | 1749 | } |
1746 | 1750 | ||
@@ -1751,6 +1755,7 @@ static int adpt_open(struct inode *inode, struct file *file) | |||
1751 | 1755 | ||
1752 | pHba->in_use = 1; | 1756 | pHba->in_use = 1; |
1753 | mutex_unlock(&adpt_configuration_lock); | 1757 | mutex_unlock(&adpt_configuration_lock); |
1758 | unlock_kernel(); | ||
1754 | 1759 | ||
1755 | return 0; | 1760 | return 0; |
1756 | } | 1761 | } |
diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c index 46771d4c81bd..822d5214692b 100644 --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c | |||
@@ -120,6 +120,7 @@ | |||
120 | #include <linux/timer.h> | 120 | #include <linux/timer.h> |
121 | #include <linux/dma-mapping.h> | 121 | #include <linux/dma-mapping.h> |
122 | #include <linux/list.h> | 122 | #include <linux/list.h> |
123 | #include <linux/smp_lock.h> | ||
123 | 124 | ||
124 | #ifdef GDTH_RTC | 125 | #ifdef GDTH_RTC |
125 | #include <linux/mc146818rtc.h> | 126 | #include <linux/mc146818rtc.h> |
@@ -4019,10 +4020,12 @@ static int gdth_open(struct inode *inode, struct file *filep) | |||
4019 | { | 4020 | { |
4020 | gdth_ha_str *ha; | 4021 | gdth_ha_str *ha; |
4021 | 4022 | ||
4023 | lock_kernel(); | ||
4022 | list_for_each_entry(ha, &gdth_instances, list) { | 4024 | list_for_each_entry(ha, &gdth_instances, list) { |
4023 | if (!ha->sdev) | 4025 | if (!ha->sdev) |
4024 | ha->sdev = scsi_get_host_dev(ha->shost); | 4026 | ha->sdev = scsi_get_host_dev(ha->shost); |
4025 | } | 4027 | } |
4028 | unlock_kernel(); | ||
4026 | 4029 | ||
4027 | TRACE(("gdth_open()\n")); | 4030 | TRACE(("gdth_open()\n")); |
4028 | return 0; | 4031 | return 0; |
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 18551aaf5e09..28c9da7d4a5c 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c | |||
@@ -46,6 +46,7 @@ | |||
46 | #include <linux/pci.h> | 46 | #include <linux/pci.h> |
47 | #include <linux/init.h> | 47 | #include <linux/init.h> |
48 | #include <linux/dma-mapping.h> | 48 | #include <linux/dma-mapping.h> |
49 | #include <linux/smp_lock.h> | ||
49 | #include <scsi/scsicam.h> | 50 | #include <scsi/scsicam.h> |
50 | 51 | ||
51 | #include "scsi.h" | 52 | #include "scsi.h" |
@@ -3272,12 +3273,12 @@ mega_init_scb(adapter_t *adapter) | |||
3272 | * @filep - unused | 3273 | * @filep - unused |
3273 | * | 3274 | * |
3274 | * Routines for the character/ioctl interface to the driver. Find out if this | 3275 | * Routines for the character/ioctl interface to the driver. Find out if this |
3275 | * is a valid open. If yes, increment the module use count so that it cannot | 3276 | * is a valid open. |
3276 | * be unloaded. | ||
3277 | */ | 3277 | */ |
3278 | static int | 3278 | static int |
3279 | megadev_open (struct inode *inode, struct file *filep) | 3279 | megadev_open (struct inode *inode, struct file *filep) |
3280 | { | 3280 | { |
3281 | cycle_kernel_lock(); | ||
3281 | /* | 3282 | /* |
3282 | * Only allow superuser to access private ioctl interface | 3283 | * Only allow superuser to access private ioctl interface |
3283 | */ | 3284 | */ |
diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c index 0ad215e27b83..ac3b280c2a72 100644 --- a/drivers/scsi/megaraid/megaraid_mm.c +++ b/drivers/scsi/megaraid/megaraid_mm.c | |||
@@ -15,6 +15,7 @@ | |||
15 | * Common management module | 15 | * Common management module |
16 | */ | 16 | */ |
17 | #include <linux/sched.h> | 17 | #include <linux/sched.h> |
18 | #include <linux/smp_lock.h> | ||
18 | #include "megaraid_mm.h" | 19 | #include "megaraid_mm.h" |
19 | 20 | ||
20 | 21 | ||
@@ -96,6 +97,7 @@ mraid_mm_open(struct inode *inode, struct file *filep) | |||
96 | */ | 97 | */ |
97 | if (!capable(CAP_SYS_ADMIN)) return (-EACCES); | 98 | if (!capable(CAP_SYS_ADMIN)) return (-EACCES); |
98 | 99 | ||
100 | cycle_kernel_lock(); | ||
99 | return 0; | 101 | return 0; |
100 | } | 102 | } |
101 | 103 | ||
diff --git a/drivers/scsi/megaraid/megaraid_sas.c b/drivers/scsi/megaraid/megaraid_sas.c index 7d84c8bbcf3f..fc7ac158476c 100644 --- a/drivers/scsi/megaraid/megaraid_sas.c +++ b/drivers/scsi/megaraid/megaraid_sas.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/spinlock.h> | 33 | #include <linux/spinlock.h> |
34 | #include <linux/interrupt.h> | 34 | #include <linux/interrupt.h> |
35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
36 | #include <linux/smp_lock.h> | ||
36 | #include <linux/uio.h> | 37 | #include <linux/uio.h> |
37 | #include <asm/uaccess.h> | 38 | #include <asm/uaccess.h> |
38 | #include <linux/fs.h> | 39 | #include <linux/fs.h> |
@@ -2863,6 +2864,7 @@ static void megasas_shutdown(struct pci_dev *pdev) | |||
2863 | */ | 2864 | */ |
2864 | static int megasas_mgmt_open(struct inode *inode, struct file *filep) | 2865 | static int megasas_mgmt_open(struct inode *inode, struct file *filep) |
2865 | { | 2866 | { |
2867 | cycle_kernel_lock(); | ||
2866 | /* | 2868 | /* |
2867 | * Allow only those users with admin rights | 2869 | * Allow only those users with admin rights |
2868 | */ | 2870 | */ |
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index 243d8becd30f..1c79f9794f4e 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c | |||
@@ -50,6 +50,7 @@ static const char * osst_version = "0.99.4"; | |||
50 | #include <linux/moduleparam.h> | 50 | #include <linux/moduleparam.h> |
51 | #include <linux/delay.h> | 51 | #include <linux/delay.h> |
52 | #include <linux/jiffies.h> | 52 | #include <linux/jiffies.h> |
53 | #include <linux/smp_lock.h> | ||
53 | #include <asm/uaccess.h> | 54 | #include <asm/uaccess.h> |
54 | #include <asm/dma.h> | 55 | #include <asm/dma.h> |
55 | #include <asm/system.h> | 56 | #include <asm/system.h> |
@@ -4359,7 +4360,7 @@ os_bypass: | |||
4359 | 4360 | ||
4360 | 4361 | ||
4361 | /* Open the device */ | 4362 | /* Open the device */ |
4362 | static int os_scsi_tape_open(struct inode * inode, struct file * filp) | 4363 | static int __os_scsi_tape_open(struct inode * inode, struct file * filp) |
4363 | { | 4364 | { |
4364 | unsigned short flags; | 4365 | unsigned short flags; |
4365 | int i, b_size, new_session = 0, retval = 0; | 4366 | int i, b_size, new_session = 0, retval = 0; |
@@ -4725,6 +4726,18 @@ err_out: | |||
4725 | return retval; | 4726 | return retval; |
4726 | } | 4727 | } |
4727 | 4728 | ||
4729 | /* BKL pushdown: spaghetti avoidance wrapper */ | ||
4730 | static int os_scsi_tape_open(struct inode * inode, struct file * filp) | ||
4731 | { | ||
4732 | int ret; | ||
4733 | |||
4734 | lock_kernel(); | ||
4735 | ret = __os_scsi_tape_open(inode, filp); | ||
4736 | unlock_kernel(); | ||
4737 | return ret; | ||
4738 | } | ||
4739 | |||
4740 | |||
4728 | 4741 | ||
4729 | /* Flush the tape buffer before close */ | 4742 | /* Flush the tape buffer before close */ |
4730 | static int os_scsi_tape_flush(struct file * filp, fl_owner_t id) | 4743 | static int os_scsi_tape_flush(struct file * filp, fl_owner_t id) |
diff --git a/drivers/scsi/scsi_tgt_if.c b/drivers/scsi/scsi_tgt_if.c index d2557dbc2dc1..0e9533f7aabc 100644 --- a/drivers/scsi/scsi_tgt_if.c +++ b/drivers/scsi/scsi_tgt_if.c | |||
@@ -21,6 +21,7 @@ | |||
21 | */ | 21 | */ |
22 | #include <linux/miscdevice.h> | 22 | #include <linux/miscdevice.h> |
23 | #include <linux/file.h> | 23 | #include <linux/file.h> |
24 | #include <linux/smp_lock.h> | ||
24 | #include <net/tcp.h> | 25 | #include <net/tcp.h> |
25 | #include <scsi/scsi.h> | 26 | #include <scsi/scsi.h> |
26 | #include <scsi/scsi_cmnd.h> | 27 | #include <scsi/scsi_cmnd.h> |
@@ -321,6 +322,7 @@ static int tgt_open(struct inode *inode, struct file *file) | |||
321 | { | 322 | { |
322 | tx_ring.tr_idx = rx_ring.tr_idx = 0; | 323 | tx_ring.tr_idx = rx_ring.tr_idx = 0; |
323 | 324 | ||
325 | cycle_kernel_lock(); | ||
324 | return 0; | 326 | return 0; |
325 | } | 327 | } |
326 | 328 | ||
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index fe694f0ee19a..fccd2e88d600 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -49,6 +49,7 @@ static int sg_version_num = 30534; /* 2 digits for each component */ | |||
49 | #include <linux/delay.h> | 49 | #include <linux/delay.h> |
50 | #include <linux/scatterlist.h> | 50 | #include <linux/scatterlist.h> |
51 | #include <linux/blktrace_api.h> | 51 | #include <linux/blktrace_api.h> |
52 | #include <linux/smp_lock.h> | ||
52 | 53 | ||
53 | #include "scsi.h" | 54 | #include "scsi.h" |
54 | #include <scsi/scsi_dbg.h> | 55 | #include <scsi/scsi_dbg.h> |
@@ -227,19 +228,26 @@ sg_open(struct inode *inode, struct file *filp) | |||
227 | int res; | 228 | int res; |
228 | int retval; | 229 | int retval; |
229 | 230 | ||
231 | lock_kernel(); | ||
230 | nonseekable_open(inode, filp); | 232 | nonseekable_open(inode, filp); |
231 | SCSI_LOG_TIMEOUT(3, printk("sg_open: dev=%d, flags=0x%x\n", dev, flags)); | 233 | SCSI_LOG_TIMEOUT(3, printk("sg_open: dev=%d, flags=0x%x\n", dev, flags)); |
232 | sdp = sg_get_dev(dev); | 234 | sdp = sg_get_dev(dev); |
233 | if ((!sdp) || (!sdp->device)) | 235 | if ((!sdp) || (!sdp->device)) { |
236 | unlock_kernel(); | ||
234 | return -ENXIO; | 237 | return -ENXIO; |
235 | if (sdp->detached) | 238 | } |
239 | if (sdp->detached) { | ||
240 | unlock_kernel(); | ||
236 | return -ENODEV; | 241 | return -ENODEV; |
242 | } | ||
237 | 243 | ||
238 | /* This driver's module count bumped by fops_get in <linux/fs.h> */ | 244 | /* This driver's module count bumped by fops_get in <linux/fs.h> */ |
239 | /* Prevent the device driver from vanishing while we sleep */ | 245 | /* Prevent the device driver from vanishing while we sleep */ |
240 | retval = scsi_device_get(sdp->device); | 246 | retval = scsi_device_get(sdp->device); |
241 | if (retval) | 247 | if (retval) { |
248 | unlock_kernel(); | ||
242 | return retval; | 249 | return retval; |
250 | } | ||
243 | 251 | ||
244 | if (!((flags & O_NONBLOCK) || | 252 | if (!((flags & O_NONBLOCK) || |
245 | scsi_block_when_processing_errors(sdp->device))) { | 253 | scsi_block_when_processing_errors(sdp->device))) { |
@@ -295,10 +303,12 @@ sg_open(struct inode *inode, struct file *filp) | |||
295 | retval = -ENOMEM; | 303 | retval = -ENOMEM; |
296 | goto error_out; | 304 | goto error_out; |
297 | } | 305 | } |
306 | unlock_kernel(); | ||
298 | return 0; | 307 | return 0; |
299 | 308 | ||
300 | error_out: | 309 | error_out: |
301 | scsi_device_put(sdp->device); | 310 | scsi_device_put(sdp->device); |
311 | unlock_kernel(); | ||
302 | return retval; | 312 | return retval; |
303 | } | 313 | } |
304 | 314 | ||
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index 6e5a5bb31311..4684cc716aa4 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
@@ -38,6 +38,7 @@ static const char *verstr = "20080224"; | |||
38 | #include <linux/cdev.h> | 38 | #include <linux/cdev.h> |
39 | #include <linux/delay.h> | 39 | #include <linux/delay.h> |
40 | #include <linux/mutex.h> | 40 | #include <linux/mutex.h> |
41 | #include <linux/smp_lock.h> | ||
41 | 42 | ||
42 | #include <asm/uaccess.h> | 43 | #include <asm/uaccess.h> |
43 | #include <asm/dma.h> | 44 | #include <asm/dma.h> |
@@ -1113,7 +1114,7 @@ static int check_tape(struct scsi_tape *STp, struct file *filp) | |||
1113 | } | 1114 | } |
1114 | 1115 | ||
1115 | 1116 | ||
1116 | /* Open the device. Needs to be called with BKL only because of incrementing the SCSI host | 1117 | /* Open the device. Needs to take the BKL only because of incrementing the SCSI host |
1117 | module count. */ | 1118 | module count. */ |
1118 | static int st_open(struct inode *inode, struct file *filp) | 1119 | static int st_open(struct inode *inode, struct file *filp) |
1119 | { | 1120 | { |
@@ -1123,6 +1124,7 @@ static int st_open(struct inode *inode, struct file *filp) | |||
1123 | int dev = TAPE_NR(inode); | 1124 | int dev = TAPE_NR(inode); |
1124 | char *name; | 1125 | char *name; |
1125 | 1126 | ||
1127 | lock_kernel(); | ||
1126 | /* | 1128 | /* |
1127 | * We really want to do nonseekable_open(inode, filp); here, but some | 1129 | * We really want to do nonseekable_open(inode, filp); here, but some |
1128 | * versions of tar incorrectly call lseek on tapes and bail out if that | 1130 | * versions of tar incorrectly call lseek on tapes and bail out if that |
@@ -1130,8 +1132,10 @@ static int st_open(struct inode *inode, struct file *filp) | |||
1130 | */ | 1132 | */ |
1131 | filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); | 1133 | filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); |
1132 | 1134 | ||
1133 | if (!(STp = scsi_tape_get(dev))) | 1135 | if (!(STp = scsi_tape_get(dev))) { |
1136 | unlock_kernel(); | ||
1134 | return -ENXIO; | 1137 | return -ENXIO; |
1138 | } | ||
1135 | 1139 | ||
1136 | write_lock(&st_dev_arr_lock); | 1140 | write_lock(&st_dev_arr_lock); |
1137 | filp->private_data = STp; | 1141 | filp->private_data = STp; |
@@ -1140,6 +1144,7 @@ static int st_open(struct inode *inode, struct file *filp) | |||
1140 | if (STp->in_use) { | 1144 | if (STp->in_use) { |
1141 | write_unlock(&st_dev_arr_lock); | 1145 | write_unlock(&st_dev_arr_lock); |
1142 | scsi_tape_put(STp); | 1146 | scsi_tape_put(STp); |
1147 | unlock_kernel(); | ||
1143 | DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); ) | 1148 | DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); ) |
1144 | return (-EBUSY); | 1149 | return (-EBUSY); |
1145 | } | 1150 | } |
@@ -1188,12 +1193,14 @@ static int st_open(struct inode *inode, struct file *filp) | |||
1188 | retval = (-EIO); | 1193 | retval = (-EIO); |
1189 | goto err_out; | 1194 | goto err_out; |
1190 | } | 1195 | } |
1196 | unlock_kernel(); | ||
1191 | return 0; | 1197 | return 0; |
1192 | 1198 | ||
1193 | err_out: | 1199 | err_out: |
1194 | normalize_buffer(STp->buffer); | 1200 | normalize_buffer(STp->buffer); |
1195 | STp->in_use = 0; | 1201 | STp->in_use = 0; |
1196 | scsi_tape_put(STp); | 1202 | scsi_tape_put(STp); |
1203 | unlock_kernel(); | ||
1197 | return retval; | 1204 | return retval; |
1198 | 1205 | ||
1199 | } | 1206 | } |
diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c index f5b60c70389b..ddbe1a5e970e 100644 --- a/drivers/spi/spidev.c +++ b/drivers/spi/spidev.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/errno.h> | 30 | #include <linux/errno.h> |
31 | #include <linux/mutex.h> | 31 | #include <linux/mutex.h> |
32 | #include <linux/slab.h> | 32 | #include <linux/slab.h> |
33 | #include <linux/smp_lock.h> | ||
33 | 34 | ||
34 | #include <linux/spi/spi.h> | 35 | #include <linux/spi/spi.h> |
35 | #include <linux/spi/spidev.h> | 36 | #include <linux/spi/spidev.h> |
@@ -464,6 +465,7 @@ static int spidev_open(struct inode *inode, struct file *filp) | |||
464 | struct spidev_data *spidev; | 465 | struct spidev_data *spidev; |
465 | int status = -ENXIO; | 466 | int status = -ENXIO; |
466 | 467 | ||
468 | lock_kernel(); | ||
467 | mutex_lock(&device_list_lock); | 469 | mutex_lock(&device_list_lock); |
468 | 470 | ||
469 | list_for_each_entry(spidev, &device_list, device_entry) { | 471 | list_for_each_entry(spidev, &device_list, device_entry) { |
@@ -489,6 +491,7 @@ static int spidev_open(struct inode *inode, struct file *filp) | |||
489 | pr_debug("spidev: nothing for minor %d\n", iminor(inode)); | 491 | pr_debug("spidev: nothing for minor %d\n", iminor(inode)); |
490 | 492 | ||
491 | mutex_unlock(&device_list_lock); | 493 | mutex_unlock(&device_list_lock); |
494 | unlock_kernel(); | ||
492 | return status; | 495 | return status; |
493 | } | 496 | } |
494 | 497 | ||
diff --git a/drivers/telephony/phonedev.c b/drivers/telephony/phonedev.c index bcea8d9b718c..4d74ba36c3a1 100644 --- a/drivers/telephony/phonedev.c +++ b/drivers/telephony/phonedev.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/errno.h> | 23 | #include <linux/errno.h> |
24 | #include <linux/phonedev.h> | 24 | #include <linux/phonedev.h> |
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/smp_lock.h> | ||
26 | #include <asm/uaccess.h> | 27 | #include <asm/uaccess.h> |
27 | #include <asm/system.h> | 28 | #include <asm/system.h> |
28 | 29 | ||
@@ -53,6 +54,7 @@ static int phone_open(struct inode *inode, struct file *file) | |||
53 | if (minor >= PHONE_NUM_DEVICES) | 54 | if (minor >= PHONE_NUM_DEVICES) |
54 | return -ENODEV; | 55 | return -ENODEV; |
55 | 56 | ||
57 | lock_kernel(); | ||
56 | mutex_lock(&phone_lock); | 58 | mutex_lock(&phone_lock); |
57 | p = phone_device[minor]; | 59 | p = phone_device[minor]; |
58 | if (p) | 60 | if (p) |
@@ -79,6 +81,7 @@ static int phone_open(struct inode *inode, struct file *file) | |||
79 | fops_put(old_fops); | 81 | fops_put(old_fops); |
80 | end: | 82 | end: |
81 | mutex_unlock(&phone_lock); | 83 | mutex_unlock(&phone_lock); |
84 | unlock_kernel(); | ||
82 | return err; | 85 | return err; |
83 | } | 86 | } |
84 | 87 | ||
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 0a12e90ad416..5a7ca2e6094d 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c | |||
@@ -297,12 +297,17 @@ static int uio_open(struct inode *inode, struct file *filep) | |||
297 | struct uio_listener *listener; | 297 | struct uio_listener *listener; |
298 | int ret = 0; | 298 | int ret = 0; |
299 | 299 | ||
300 | lock_kernel(); | ||
300 | idev = idr_find(&uio_idr, iminor(inode)); | 301 | idev = idr_find(&uio_idr, iminor(inode)); |
301 | if (!idev) | 302 | if (!idev) { |
302 | return -ENODEV; | 303 | ret = -ENODEV; |
304 | goto out; | ||
305 | } | ||
303 | 306 | ||
304 | if (!try_module_get(idev->owner)) | 307 | if (!try_module_get(idev->owner)) { |
305 | return -ENODEV; | 308 | ret = -ENODEV; |
309 | goto out; | ||
310 | } | ||
306 | 311 | ||
307 | listener = kmalloc(sizeof(*listener), GFP_KERNEL); | 312 | listener = kmalloc(sizeof(*listener), GFP_KERNEL); |
308 | if (!listener) { | 313 | if (!listener) { |
@@ -319,7 +324,7 @@ static int uio_open(struct inode *inode, struct file *filep) | |||
319 | if (ret) | 324 | if (ret) |
320 | goto err_infoopen; | 325 | goto err_infoopen; |
321 | } | 326 | } |
322 | 327 | unlock_kernel(); | |
323 | return 0; | 328 | return 0; |
324 | 329 | ||
325 | err_infoopen: | 330 | err_infoopen: |
@@ -329,6 +334,8 @@ err_alloc_listener: | |||
329 | 334 | ||
330 | module_put(idev->owner); | 335 | module_put(idev->owner); |
331 | 336 | ||
337 | out: | ||
338 | unlock_kernel(); | ||
332 | return ret; | 339 | return ret; |
333 | } | 340 | } |
334 | 341 | ||
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index de17738f3acb..9218cca21043 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -565,6 +565,7 @@ static int usbdev_open(struct inode *inode, struct file *file) | |||
565 | struct dev_state *ps; | 565 | struct dev_state *ps; |
566 | int ret; | 566 | int ret; |
567 | 567 | ||
568 | lock_kernel(); | ||
568 | /* Protect against simultaneous removal or release */ | 569 | /* Protect against simultaneous removal or release */ |
569 | mutex_lock(&usbfs_mutex); | 570 | mutex_lock(&usbfs_mutex); |
570 | 571 | ||
@@ -611,6 +612,7 @@ static int usbdev_open(struct inode *inode, struct file *file) | |||
611 | if (ret) | 612 | if (ret) |
612 | kfree(ps); | 613 | kfree(ps); |
613 | mutex_unlock(&usbfs_mutex); | 614 | mutex_unlock(&usbfs_mutex); |
615 | unlock_kernel(); | ||
614 | return ret; | 616 | return ret; |
615 | } | 617 | } |
616 | 618 | ||
diff --git a/drivers/usb/core/file.c b/drivers/usb/core/file.c index 8133c99c6c5c..c6a95395e52a 100644 --- a/drivers/usb/core/file.c +++ b/drivers/usb/core/file.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
20 | #include <linux/rwsem.h> | 20 | #include <linux/rwsem.h> |
21 | #include <linux/smp_lock.h> | ||
21 | #include <linux/usb.h> | 22 | #include <linux/usb.h> |
22 | 23 | ||
23 | #include "usb.h" | 24 | #include "usb.h" |
@@ -33,6 +34,7 @@ static int usb_open(struct inode * inode, struct file * file) | |||
33 | int err = -ENODEV; | 34 | int err = -ENODEV; |
34 | const struct file_operations *old_fops, *new_fops = NULL; | 35 | const struct file_operations *old_fops, *new_fops = NULL; |
35 | 36 | ||
37 | lock_kernel(); | ||
36 | down_read(&minor_rwsem); | 38 | down_read(&minor_rwsem); |
37 | c = usb_minors[minor]; | 39 | c = usb_minors[minor]; |
38 | 40 | ||
@@ -51,6 +53,7 @@ static int usb_open(struct inode * inode, struct file * file) | |||
51 | fops_put(old_fops); | 53 | fops_put(old_fops); |
52 | done: | 54 | done: |
53 | up_read(&minor_rwsem); | 55 | up_read(&minor_rwsem); |
56 | unlock_kernel(); | ||
54 | return err; | 57 | return err; |
55 | } | 58 | } |
56 | 59 | ||
diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index 76be75e3ab8f..ec8f2eb041ca 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c | |||
@@ -462,6 +462,7 @@ printer_open(struct inode *inode, struct file *fd) | |||
462 | unsigned long flags; | 462 | unsigned long flags; |
463 | int ret = -EBUSY; | 463 | int ret = -EBUSY; |
464 | 464 | ||
465 | lock_kernel(); | ||
465 | dev = container_of(inode->i_cdev, struct printer_dev, printer_cdev); | 466 | dev = container_of(inode->i_cdev, struct printer_dev, printer_cdev); |
466 | 467 | ||
467 | spin_lock_irqsave(&dev->lock, flags); | 468 | spin_lock_irqsave(&dev->lock, flags); |
@@ -477,7 +478,7 @@ printer_open(struct inode *inode, struct file *fd) | |||
477 | spin_unlock_irqrestore(&dev->lock, flags); | 478 | spin_unlock_irqrestore(&dev->lock, flags); |
478 | 479 | ||
479 | DBG(dev, "printer_open returned %x\n", ret); | 480 | DBG(dev, "printer_open returned %x\n", ret); |
480 | 481 | unlock_kernel(); | |
481 | return ret; | 482 | return ret; |
482 | } | 483 | } |
483 | 484 | ||
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c index 49145534e06e..293a46247c3b 100644 --- a/drivers/usb/mon/mon_bin.c +++ b/drivers/usb/mon/mon_bin.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/poll.h> | 15 | #include <linux/poll.h> |
16 | #include <linux/compat.h> | 16 | #include <linux/compat.h> |
17 | #include <linux/mm.h> | 17 | #include <linux/mm.h> |
18 | #include <linux/smp_lock.h> | ||
18 | 19 | ||
19 | #include <asm/uaccess.h> | 20 | #include <asm/uaccess.h> |
20 | 21 | ||
@@ -527,14 +528,17 @@ static int mon_bin_open(struct inode *inode, struct file *file) | |||
527 | size_t size; | 528 | size_t size; |
528 | int rc; | 529 | int rc; |
529 | 530 | ||
531 | lock_kernel(); | ||
530 | mutex_lock(&mon_lock); | 532 | mutex_lock(&mon_lock); |
531 | if ((mbus = mon_bus_lookup(iminor(inode))) == NULL) { | 533 | if ((mbus = mon_bus_lookup(iminor(inode))) == NULL) { |
532 | mutex_unlock(&mon_lock); | 534 | mutex_unlock(&mon_lock); |
535 | unlock_kernel(); | ||
533 | return -ENODEV; | 536 | return -ENODEV; |
534 | } | 537 | } |
535 | if (mbus != &mon_bus0 && mbus->u_bus == NULL) { | 538 | if (mbus != &mon_bus0 && mbus->u_bus == NULL) { |
536 | printk(KERN_ERR TAG ": consistency error on open\n"); | 539 | printk(KERN_ERR TAG ": consistency error on open\n"); |
537 | mutex_unlock(&mon_lock); | 540 | mutex_unlock(&mon_lock); |
541 | unlock_kernel(); | ||
538 | return -ENODEV; | 542 | return -ENODEV; |
539 | } | 543 | } |
540 | 544 | ||
@@ -568,6 +572,7 @@ static int mon_bin_open(struct inode *inode, struct file *file) | |||
568 | 572 | ||
569 | file->private_data = rp; | 573 | file->private_data = rp; |
570 | mutex_unlock(&mon_lock); | 574 | mutex_unlock(&mon_lock); |
575 | unlock_kernel(); | ||
571 | return 0; | 576 | return 0; |
572 | 577 | ||
573 | err_allocbuff: | 578 | err_allocbuff: |
@@ -576,6 +581,7 @@ err_allocvec: | |||
576 | kfree(rp); | 581 | kfree(rp); |
577 | err_alloc: | 582 | err_alloc: |
578 | mutex_unlock(&mon_lock); | 583 | mutex_unlock(&mon_lock); |
584 | unlock_kernel(); | ||
579 | return rc; | 585 | return rc; |
580 | } | 586 | } |
581 | 587 | ||
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index 776f7fcd2fbf..33ebdb198daf 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c | |||
@@ -1326,20 +1326,27 @@ fb_open(struct inode *inode, struct file *file) | |||
1326 | 1326 | ||
1327 | if (fbidx >= FB_MAX) | 1327 | if (fbidx >= FB_MAX) |
1328 | return -ENODEV; | 1328 | return -ENODEV; |
1329 | lock_kernel(); | ||
1329 | #ifdef CONFIG_KMOD | 1330 | #ifdef CONFIG_KMOD |
1330 | if (!(info = registered_fb[fbidx])) | 1331 | if (!(info = registered_fb[fbidx])) |
1331 | try_to_load(fbidx); | 1332 | try_to_load(fbidx); |
1332 | #endif /* CONFIG_KMOD */ | 1333 | #endif /* CONFIG_KMOD */ |
1333 | if (!(info = registered_fb[fbidx])) | 1334 | if (!(info = registered_fb[fbidx])) { |
1334 | return -ENODEV; | 1335 | res = -ENODEV; |
1335 | if (!try_module_get(info->fbops->owner)) | 1336 | goto out; |
1336 | return -ENODEV; | 1337 | } |
1338 | if (!try_module_get(info->fbops->owner)) { | ||
1339 | res = -ENODEV; | ||
1340 | goto out; | ||
1341 | } | ||
1337 | file->private_data = info; | 1342 | file->private_data = info; |
1338 | if (info->fbops->fb_open) { | 1343 | if (info->fbops->fb_open) { |
1339 | res = info->fbops->fb_open(info,1); | 1344 | res = info->fbops->fb_open(info,1); |
1340 | if (res) | 1345 | if (res) |
1341 | module_put(info->fbops->owner); | 1346 | module_put(info->fbops->owner); |
1342 | } | 1347 | } |
1348 | out: | ||
1349 | unlock_kernel(); | ||
1343 | return res; | 1350 | return res; |
1344 | } | 1351 | } |
1345 | 1352 | ||
diff --git a/fs/char_dev.c b/fs/char_dev.c index 68e510b88457..3cb7cda3d780 100644 --- a/fs/char_dev.c +++ b/fs/char_dev.c | |||
@@ -373,6 +373,8 @@ static int chrdev_open(struct inode *inode, struct file *filp) | |||
373 | return -ENXIO; | 373 | return -ENXIO; |
374 | new = container_of(kobj, struct cdev, kobj); | 374 | new = container_of(kobj, struct cdev, kobj); |
375 | spin_lock(&cdev_lock); | 375 | spin_lock(&cdev_lock); |
376 | /* Check i_cdev again in case somebody beat us to it while | ||
377 | we dropped the lock. */ | ||
376 | p = inode->i_cdev; | 378 | p = inode->i_cdev; |
377 | if (!p) { | 379 | if (!p) { |
378 | inode->i_cdev = p = new; | 380 | inode->i_cdev = p = new; |
@@ -392,11 +394,8 @@ static int chrdev_open(struct inode *inode, struct file *filp) | |||
392 | cdev_put(p); | 394 | cdev_put(p); |
393 | return -ENXIO; | 395 | return -ENXIO; |
394 | } | 396 | } |
395 | if (filp->f_op->open) { | 397 | if (filp->f_op->open) |
396 | lock_kernel(); | ||
397 | ret = filp->f_op->open(inode,filp); | 398 | ret = filp->f_op->open(inode,filp); |
398 | unlock_kernel(); | ||
399 | } | ||
400 | if (ret) | 399 | if (ret) |
401 | cdev_put(p); | 400 | cdev_put(p); |
402 | return ret; | 401 | return ret; |
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 86b4d5f405ae..22857c639df5 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
@@ -612,7 +612,7 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int origin) | |||
612 | if (retval < 0) | 612 | if (retval < 0) |
613 | return (loff_t)retval; | 613 | return (loff_t)retval; |
614 | } | 614 | } |
615 | return remote_llseek(file, offset, origin); | 615 | return generic_file_llseek_unlocked(file, offset, origin); |
616 | } | 616 | } |
617 | 617 | ||
618 | struct file_system_type cifs_fs_type = { | 618 | struct file_system_type cifs_fs_type = { |
diff --git a/fs/dlm/user.c b/fs/dlm/user.c index ebbcf38fd33b..f976f303c196 100644 --- a/fs/dlm/user.c +++ b/fs/dlm/user.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/poll.h> | 15 | #include <linux/poll.h> |
16 | #include <linux/signal.h> | 16 | #include <linux/signal.h> |
17 | #include <linux/spinlock.h> | 17 | #include <linux/spinlock.h> |
18 | #include <linux/smp_lock.h> | ||
18 | #include <linux/dlm.h> | 19 | #include <linux/dlm.h> |
19 | #include <linux/dlm_device.h> | 20 | #include <linux/dlm_device.h> |
20 | 21 | ||
@@ -618,13 +619,17 @@ static int device_open(struct inode *inode, struct file *file) | |||
618 | struct dlm_user_proc *proc; | 619 | struct dlm_user_proc *proc; |
619 | struct dlm_ls *ls; | 620 | struct dlm_ls *ls; |
620 | 621 | ||
622 | lock_kernel(); | ||
621 | ls = dlm_find_lockspace_device(iminor(inode)); | 623 | ls = dlm_find_lockspace_device(iminor(inode)); |
622 | if (!ls) | 624 | if (!ls) { |
625 | unlock_kernel(); | ||
623 | return -ENOENT; | 626 | return -ENOENT; |
627 | } | ||
624 | 628 | ||
625 | proc = kzalloc(sizeof(struct dlm_user_proc), GFP_KERNEL); | 629 | proc = kzalloc(sizeof(struct dlm_user_proc), GFP_KERNEL); |
626 | if (!proc) { | 630 | if (!proc) { |
627 | dlm_put_lockspace(ls); | 631 | dlm_put_lockspace(ls); |
632 | unlock_kernel(); | ||
628 | return -ENOMEM; | 633 | return -ENOMEM; |
629 | } | 634 | } |
630 | 635 | ||
@@ -636,6 +641,7 @@ static int device_open(struct inode *inode, struct file *file) | |||
636 | spin_lock_init(&proc->locks_spin); | 641 | spin_lock_init(&proc->locks_spin); |
637 | init_waitqueue_head(&proc->wait); | 642 | init_waitqueue_head(&proc->wait); |
638 | file->private_data = proc; | 643 | file->private_data = proc; |
644 | unlock_kernel(); | ||
639 | 645 | ||
640 | return 0; | 646 | return 0; |
641 | } | 647 | } |
@@ -870,6 +876,7 @@ static unsigned int device_poll(struct file *file, poll_table *wait) | |||
870 | 876 | ||
871 | static int ctl_device_open(struct inode *inode, struct file *file) | 877 | static int ctl_device_open(struct inode *inode, struct file *file) |
872 | { | 878 | { |
879 | cycle_kernel_lock(); | ||
873 | file->private_data = NULL; | 880 | file->private_data = NULL; |
874 | return 0; | 881 | return 0; |
875 | } | 882 | } |
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index 2258b8f654a6..24749bf0668f 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <linux/security.h> | 30 | #include <linux/security.h> |
31 | #include <linux/compat.h> | 31 | #include <linux/compat.h> |
32 | #include <linux/fs_stack.h> | 32 | #include <linux/fs_stack.h> |
33 | #include <linux/smp_lock.h> | ||
33 | #include "ecryptfs_kernel.h" | 34 | #include "ecryptfs_kernel.h" |
34 | 35 | ||
35 | /** | 36 | /** |
@@ -277,9 +278,11 @@ static int ecryptfs_fasync(int fd, struct file *file, int flag) | |||
277 | int rc = 0; | 278 | int rc = 0; |
278 | struct file *lower_file = NULL; | 279 | struct file *lower_file = NULL; |
279 | 280 | ||
281 | lock_kernel(); | ||
280 | lower_file = ecryptfs_file_to_lower(file); | 282 | lower_file = ecryptfs_file_to_lower(file); |
281 | if (lower_file->f_op && lower_file->f_op->fasync) | 283 | if (lower_file->f_op && lower_file->f_op->fasync) |
282 | rc = lower_file->f_op->fasync(fd, lower_file, flag); | 284 | rc = lower_file->f_op->fasync(fd, lower_file, flag); |
285 | unlock_kernel(); | ||
283 | return rc; | 286 | return rc; |
284 | } | 287 | } |
285 | 288 | ||
diff --git a/fs/fat/cache.c b/fs/fat/cache.c index fda25479af26..3a9ecac8d61f 100644 --- a/fs/fat/cache.c +++ b/fs/fat/cache.c | |||
@@ -61,7 +61,7 @@ void fat_cache_destroy(void) | |||
61 | 61 | ||
62 | static inline struct fat_cache *fat_cache_alloc(struct inode *inode) | 62 | static inline struct fat_cache *fat_cache_alloc(struct inode *inode) |
63 | { | 63 | { |
64 | return kmem_cache_alloc(fat_cache_cachep, GFP_KERNEL); | 64 | return kmem_cache_alloc(fat_cache_cachep, GFP_NOFS); |
65 | } | 65 | } |
66 | 66 | ||
67 | static inline void fat_cache_free(struct fat_cache *cache) | 67 | static inline void fat_cache_free(struct fat_cache *cache) |
diff --git a/fs/fat/dir.c b/fs/fat/dir.c index 486725ee99ae..34541d06e626 100644 --- a/fs/fat/dir.c +++ b/fs/fat/dir.c | |||
@@ -472,7 +472,7 @@ static int __fat_readdir(struct inode *inode, struct file *filp, void *dirent, | |||
472 | loff_t cpos; | 472 | loff_t cpos; |
473 | int ret = 0; | 473 | int ret = 0; |
474 | 474 | ||
475 | lock_kernel(); | 475 | lock_super(sb); |
476 | 476 | ||
477 | cpos = filp->f_pos; | 477 | cpos = filp->f_pos; |
478 | /* Fake . and .. for the root directory. */ | 478 | /* Fake . and .. for the root directory. */ |
@@ -654,7 +654,7 @@ FillFailed: | |||
654 | if (unicode) | 654 | if (unicode) |
655 | __putname(unicode); | 655 | __putname(unicode); |
656 | out: | 656 | out: |
657 | unlock_kernel(); | 657 | unlock_super(sb); |
658 | return ret; | 658 | return ret; |
659 | } | 659 | } |
660 | 660 | ||
diff --git a/fs/fat/file.c b/fs/fat/file.c index 771326b8047e..c672df4036e9 100644 --- a/fs/fat/file.c +++ b/fs/fat/file.c | |||
@@ -11,7 +11,6 @@ | |||
11 | #include <linux/mount.h> | 11 | #include <linux/mount.h> |
12 | #include <linux/time.h> | 12 | #include <linux/time.h> |
13 | #include <linux/msdos_fs.h> | 13 | #include <linux/msdos_fs.h> |
14 | #include <linux/smp_lock.h> | ||
15 | #include <linux/buffer_head.h> | 14 | #include <linux/buffer_head.h> |
16 | #include <linux/writeback.h> | 15 | #include <linux/writeback.h> |
17 | #include <linux/backing-dev.h> | 16 | #include <linux/backing-dev.h> |
@@ -242,9 +241,7 @@ void fat_truncate(struct inode *inode) | |||
242 | 241 | ||
243 | nr_clusters = (inode->i_size + (cluster_size - 1)) >> sbi->cluster_bits; | 242 | nr_clusters = (inode->i_size + (cluster_size - 1)) >> sbi->cluster_bits; |
244 | 243 | ||
245 | lock_kernel(); | ||
246 | fat_free(inode, nr_clusters); | 244 | fat_free(inode, nr_clusters); |
247 | unlock_kernel(); | ||
248 | fat_flush_inodes(inode->i_sb, inode, NULL); | 245 | fat_flush_inodes(inode->i_sb, inode, NULL); |
249 | } | 246 | } |
250 | 247 | ||
@@ -310,8 +307,6 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr) | |||
310 | int error = 0; | 307 | int error = 0; |
311 | unsigned int ia_valid; | 308 | unsigned int ia_valid; |
312 | 309 | ||
313 | lock_kernel(); | ||
314 | |||
315 | /* | 310 | /* |
316 | * Expand the file. Since inode_setattr() updates ->i_size | 311 | * Expand the file. Since inode_setattr() updates ->i_size |
317 | * before calling the ->truncate(), but FAT needs to fill the | 312 | * before calling the ->truncate(), but FAT needs to fill the |
@@ -366,7 +361,6 @@ int fat_setattr(struct dentry *dentry, struct iattr *attr) | |||
366 | 361 | ||
367 | error = inode_setattr(inode, attr); | 362 | error = inode_setattr(inode, attr); |
368 | out: | 363 | out: |
369 | unlock_kernel(); | ||
370 | return error; | 364 | return error; |
371 | } | 365 | } |
372 | EXPORT_SYMBOL_GPL(fat_setattr); | 366 | EXPORT_SYMBOL_GPL(fat_setattr); |
diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 4e0a3dd9d677..46a4508ffd2e 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c | |||
@@ -440,14 +440,13 @@ static void fat_delete_inode(struct inode *inode) | |||
440 | 440 | ||
441 | static void fat_clear_inode(struct inode *inode) | 441 | static void fat_clear_inode(struct inode *inode) |
442 | { | 442 | { |
443 | struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb); | 443 | struct super_block *sb = inode->i_sb; |
444 | struct msdos_sb_info *sbi = MSDOS_SB(sb); | ||
444 | 445 | ||
445 | lock_kernel(); | ||
446 | spin_lock(&sbi->inode_hash_lock); | 446 | spin_lock(&sbi->inode_hash_lock); |
447 | fat_cache_inval_inode(inode); | 447 | fat_cache_inval_inode(inode); |
448 | hlist_del_init(&MSDOS_I(inode)->i_fat_hash); | 448 | hlist_del_init(&MSDOS_I(inode)->i_fat_hash); |
449 | spin_unlock(&sbi->inode_hash_lock); | 449 | spin_unlock(&sbi->inode_hash_lock); |
450 | unlock_kernel(); | ||
451 | } | 450 | } |
452 | 451 | ||
453 | static void fat_write_super(struct super_block *sb) | 452 | static void fat_write_super(struct super_block *sb) |
@@ -485,7 +484,7 @@ static struct kmem_cache *fat_inode_cachep; | |||
485 | static struct inode *fat_alloc_inode(struct super_block *sb) | 484 | static struct inode *fat_alloc_inode(struct super_block *sb) |
486 | { | 485 | { |
487 | struct msdos_inode_info *ei; | 486 | struct msdos_inode_info *ei; |
488 | ei = kmem_cache_alloc(fat_inode_cachep, GFP_KERNEL); | 487 | ei = kmem_cache_alloc(fat_inode_cachep, GFP_NOFS); |
489 | if (!ei) | 488 | if (!ei) |
490 | return NULL; | 489 | return NULL; |
491 | return &ei->vfs_inode; | 490 | return &ei->vfs_inode; |
@@ -567,7 +566,7 @@ retry: | |||
567 | if (inode->i_ino == MSDOS_ROOT_INO || !i_pos) | 566 | if (inode->i_ino == MSDOS_ROOT_INO || !i_pos) |
568 | return 0; | 567 | return 0; |
569 | 568 | ||
570 | lock_kernel(); | 569 | lock_super(sb); |
571 | bh = sb_bread(sb, i_pos >> sbi->dir_per_block_bits); | 570 | bh = sb_bread(sb, i_pos >> sbi->dir_per_block_bits); |
572 | if (!bh) { | 571 | if (!bh) { |
573 | printk(KERN_ERR "FAT: unable to read inode block " | 572 | printk(KERN_ERR "FAT: unable to read inode block " |
@@ -579,7 +578,7 @@ retry: | |||
579 | if (i_pos != MSDOS_I(inode)->i_pos) { | 578 | if (i_pos != MSDOS_I(inode)->i_pos) { |
580 | spin_unlock(&sbi->inode_hash_lock); | 579 | spin_unlock(&sbi->inode_hash_lock); |
581 | brelse(bh); | 580 | brelse(bh); |
582 | unlock_kernel(); | 581 | unlock_super(sb); |
583 | goto retry; | 582 | goto retry; |
584 | } | 583 | } |
585 | 584 | ||
@@ -606,7 +605,7 @@ retry: | |||
606 | err = sync_dirty_buffer(bh); | 605 | err = sync_dirty_buffer(bh); |
607 | brelse(bh); | 606 | brelse(bh); |
608 | out: | 607 | out: |
609 | unlock_kernel(); | 608 | unlock_super(sb); |
610 | return err; | 609 | return err; |
611 | } | 610 | } |
612 | 611 | ||
@@ -736,6 +735,7 @@ fat_encode_fh(struct dentry *de, __u32 *fh, int *lenp, int connectable) | |||
736 | 735 | ||
737 | static struct dentry *fat_get_parent(struct dentry *child) | 736 | static struct dentry *fat_get_parent(struct dentry *child) |
738 | { | 737 | { |
738 | struct super_block *sb = child->d_sb; | ||
739 | struct buffer_head *bh; | 739 | struct buffer_head *bh; |
740 | struct msdos_dir_entry *de; | 740 | struct msdos_dir_entry *de; |
741 | loff_t i_pos; | 741 | loff_t i_pos; |
@@ -743,14 +743,14 @@ static struct dentry *fat_get_parent(struct dentry *child) | |||
743 | struct inode *inode; | 743 | struct inode *inode; |
744 | int err; | 744 | int err; |
745 | 745 | ||
746 | lock_kernel(); | 746 | lock_super(sb); |
747 | 747 | ||
748 | err = fat_get_dotdot_entry(child->d_inode, &bh, &de, &i_pos); | 748 | err = fat_get_dotdot_entry(child->d_inode, &bh, &de, &i_pos); |
749 | if (err) { | 749 | if (err) { |
750 | parent = ERR_PTR(err); | 750 | parent = ERR_PTR(err); |
751 | goto out; | 751 | goto out; |
752 | } | 752 | } |
753 | inode = fat_build_inode(child->d_sb, de, i_pos); | 753 | inode = fat_build_inode(sb, de, i_pos); |
754 | brelse(bh); | 754 | brelse(bh); |
755 | if (IS_ERR(inode)) { | 755 | if (IS_ERR(inode)) { |
756 | parent = ERR_CAST(inode); | 756 | parent = ERR_CAST(inode); |
@@ -762,7 +762,7 @@ static struct dentry *fat_get_parent(struct dentry *child) | |||
762 | parent = ERR_PTR(-ENOMEM); | 762 | parent = ERR_PTR(-ENOMEM); |
763 | } | 763 | } |
764 | out: | 764 | out: |
765 | unlock_kernel(); | 765 | unlock_super(sb); |
766 | 766 | ||
767 | return parent; | 767 | return parent; |
768 | } | 768 | } |
@@ -1172,6 +1172,12 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, | |||
1172 | long error; | 1172 | long error; |
1173 | char buf[50]; | 1173 | char buf[50]; |
1174 | 1174 | ||
1175 | /* | ||
1176 | * GFP_KERNEL is ok here, because while we do hold the | ||
1177 | * supeblock lock, memory pressure can't call back into | ||
1178 | * the filesystem, since we're only just about to mount | ||
1179 | * it and have no inodes etc active! | ||
1180 | */ | ||
1175 | sbi = kzalloc(sizeof(struct msdos_sb_info), GFP_KERNEL); | 1181 | sbi = kzalloc(sizeof(struct msdos_sb_info), GFP_KERNEL); |
1176 | if (!sbi) | 1182 | if (!sbi) |
1177 | return -ENOMEM; | 1183 | return -ENOMEM; |
diff --git a/fs/fcntl.c b/fs/fcntl.c index bfd776509a72..330a7d782591 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/fdtable.h> | 12 | #include <linux/fdtable.h> |
13 | #include <linux/capability.h> | 13 | #include <linux/capability.h> |
14 | #include <linux/dnotify.h> | 14 | #include <linux/dnotify.h> |
15 | #include <linux/smp_lock.h> | ||
16 | #include <linux/slab.h> | 15 | #include <linux/slab.h> |
17 | #include <linux/module.h> | 16 | #include <linux/module.h> |
18 | #include <linux/security.h> | 17 | #include <linux/security.h> |
@@ -227,7 +226,6 @@ static int setfl(int fd, struct file * filp, unsigned long arg) | |||
227 | if (error) | 226 | if (error) |
228 | return error; | 227 | return error; |
229 | 228 | ||
230 | lock_kernel(); | ||
231 | if ((arg ^ filp->f_flags) & FASYNC) { | 229 | if ((arg ^ filp->f_flags) & FASYNC) { |
232 | if (filp->f_op && filp->f_op->fasync) { | 230 | if (filp->f_op && filp->f_op->fasync) { |
233 | error = filp->f_op->fasync(fd, filp, (arg & FASYNC) != 0); | 231 | error = filp->f_op->fasync(fd, filp, (arg & FASYNC) != 0); |
@@ -238,7 +236,6 @@ static int setfl(int fd, struct file * filp, unsigned long arg) | |||
238 | 236 | ||
239 | filp->f_flags = (arg & SETFL_MASK) | (filp->f_flags & ~SETFL_MASK); | 237 | filp->f_flags = (arg & SETFL_MASK) | (filp->f_flags & ~SETFL_MASK); |
240 | out: | 238 | out: |
241 | unlock_kernel(); | ||
242 | return error; | 239 | return error; |
243 | } | 240 | } |
244 | 241 | ||
diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c index e1b7d525a066..24dd59450088 100644 --- a/fs/gfs2/ops_file.c +++ b/fs/gfs2/ops_file.c | |||
@@ -62,11 +62,11 @@ static loff_t gfs2_llseek(struct file *file, loff_t offset, int origin) | |||
62 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, | 62 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, |
63 | &i_gh); | 63 | &i_gh); |
64 | if (!error) { | 64 | if (!error) { |
65 | error = remote_llseek(file, offset, origin); | 65 | error = generic_file_llseek_unlocked(file, offset, origin); |
66 | gfs2_glock_dq_uninit(&i_gh); | 66 | gfs2_glock_dq_uninit(&i_gh); |
67 | } | 67 | } |
68 | } else | 68 | } else |
69 | error = remote_llseek(file, offset, origin); | 69 | error = generic_file_llseek_unlocked(file, offset, origin); |
70 | 70 | ||
71 | return error; | 71 | return error; |
72 | } | 72 | } |
diff --git a/fs/msdos/namei.c b/fs/msdos/namei.c index 05ff4f1d7026..1f7f2956412a 100644 --- a/fs/msdos/namei.c +++ b/fs/msdos/namei.c | |||
@@ -214,7 +214,7 @@ static struct dentry *msdos_lookup(struct inode *dir, struct dentry *dentry, | |||
214 | 214 | ||
215 | dentry->d_op = &msdos_dentry_operations; | 215 | dentry->d_op = &msdos_dentry_operations; |
216 | 216 | ||
217 | lock_kernel(); | 217 | lock_super(sb); |
218 | res = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo); | 218 | res = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo); |
219 | if (res == -ENOENT) | 219 | if (res == -ENOENT) |
220 | goto add; | 220 | goto add; |
@@ -232,7 +232,7 @@ add: | |||
232 | if (dentry) | 232 | if (dentry) |
233 | dentry->d_op = &msdos_dentry_operations; | 233 | dentry->d_op = &msdos_dentry_operations; |
234 | out: | 234 | out: |
235 | unlock_kernel(); | 235 | unlock_super(sb); |
236 | if (!res) | 236 | if (!res) |
237 | return dentry; | 237 | return dentry; |
238 | return ERR_PTR(res); | 238 | return ERR_PTR(res); |
@@ -286,7 +286,7 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, int mode, | |||
286 | unsigned char msdos_name[MSDOS_NAME]; | 286 | unsigned char msdos_name[MSDOS_NAME]; |
287 | int err, is_hid; | 287 | int err, is_hid; |
288 | 288 | ||
289 | lock_kernel(); | 289 | lock_super(sb); |
290 | 290 | ||
291 | err = msdos_format_name(dentry->d_name.name, dentry->d_name.len, | 291 | err = msdos_format_name(dentry->d_name.name, dentry->d_name.len, |
292 | msdos_name, &MSDOS_SB(sb)->options); | 292 | msdos_name, &MSDOS_SB(sb)->options); |
@@ -315,7 +315,7 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, int mode, | |||
315 | 315 | ||
316 | d_instantiate(dentry, inode); | 316 | d_instantiate(dentry, inode); |
317 | out: | 317 | out: |
318 | unlock_kernel(); | 318 | unlock_super(sb); |
319 | if (!err) | 319 | if (!err) |
320 | err = fat_flush_inodes(sb, dir, inode); | 320 | err = fat_flush_inodes(sb, dir, inode); |
321 | return err; | 321 | return err; |
@@ -324,11 +324,12 @@ out: | |||
324 | /***** Remove a directory */ | 324 | /***** Remove a directory */ |
325 | static int msdos_rmdir(struct inode *dir, struct dentry *dentry) | 325 | static int msdos_rmdir(struct inode *dir, struct dentry *dentry) |
326 | { | 326 | { |
327 | struct super_block *sb = dir->i_sb; | ||
327 | struct inode *inode = dentry->d_inode; | 328 | struct inode *inode = dentry->d_inode; |
328 | struct fat_slot_info sinfo; | 329 | struct fat_slot_info sinfo; |
329 | int err; | 330 | int err; |
330 | 331 | ||
331 | lock_kernel(); | 332 | lock_super(sb); |
332 | /* | 333 | /* |
333 | * Check whether the directory is not in use, then check | 334 | * Check whether the directory is not in use, then check |
334 | * whether it is empty. | 335 | * whether it is empty. |
@@ -349,9 +350,9 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry) | |||
349 | inode->i_ctime = CURRENT_TIME_SEC; | 350 | inode->i_ctime = CURRENT_TIME_SEC; |
350 | fat_detach(inode); | 351 | fat_detach(inode); |
351 | out: | 352 | out: |
352 | unlock_kernel(); | 353 | unlock_super(sb); |
353 | if (!err) | 354 | if (!err) |
354 | err = fat_flush_inodes(inode->i_sb, dir, inode); | 355 | err = fat_flush_inodes(sb, dir, inode); |
355 | 356 | ||
356 | return err; | 357 | return err; |
357 | } | 358 | } |
@@ -366,7 +367,7 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
366 | struct timespec ts; | 367 | struct timespec ts; |
367 | int err, is_hid, cluster; | 368 | int err, is_hid, cluster; |
368 | 369 | ||
369 | lock_kernel(); | 370 | lock_super(sb); |
370 | 371 | ||
371 | err = msdos_format_name(dentry->d_name.name, dentry->d_name.len, | 372 | err = msdos_format_name(dentry->d_name.name, dentry->d_name.len, |
372 | msdos_name, &MSDOS_SB(sb)->options); | 373 | msdos_name, &MSDOS_SB(sb)->options); |
@@ -404,14 +405,14 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
404 | 405 | ||
405 | d_instantiate(dentry, inode); | 406 | d_instantiate(dentry, inode); |
406 | 407 | ||
407 | unlock_kernel(); | 408 | unlock_super(sb); |
408 | fat_flush_inodes(sb, dir, inode); | 409 | fat_flush_inodes(sb, dir, inode); |
409 | return 0; | 410 | return 0; |
410 | 411 | ||
411 | out_free: | 412 | out_free: |
412 | fat_free_clusters(dir, cluster); | 413 | fat_free_clusters(dir, cluster); |
413 | out: | 414 | out: |
414 | unlock_kernel(); | 415 | unlock_super(sb); |
415 | return err; | 416 | return err; |
416 | } | 417 | } |
417 | 418 | ||
@@ -419,10 +420,11 @@ out: | |||
419 | static int msdos_unlink(struct inode *dir, struct dentry *dentry) | 420 | static int msdos_unlink(struct inode *dir, struct dentry *dentry) |
420 | { | 421 | { |
421 | struct inode *inode = dentry->d_inode; | 422 | struct inode *inode = dentry->d_inode; |
423 | struct super_block *sb= inode->i_sb; | ||
422 | struct fat_slot_info sinfo; | 424 | struct fat_slot_info sinfo; |
423 | int err; | 425 | int err; |
424 | 426 | ||
425 | lock_kernel(); | 427 | lock_super(sb); |
426 | err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo); | 428 | err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo); |
427 | if (err) | 429 | if (err) |
428 | goto out; | 430 | goto out; |
@@ -434,9 +436,9 @@ static int msdos_unlink(struct inode *dir, struct dentry *dentry) | |||
434 | inode->i_ctime = CURRENT_TIME_SEC; | 436 | inode->i_ctime = CURRENT_TIME_SEC; |
435 | fat_detach(inode); | 437 | fat_detach(inode); |
436 | out: | 438 | out: |
437 | unlock_kernel(); | 439 | unlock_super(sb); |
438 | if (!err) | 440 | if (!err) |
439 | err = fat_flush_inodes(inode->i_sb, dir, inode); | 441 | err = fat_flush_inodes(sb, dir, inode); |
440 | 442 | ||
441 | return err; | 443 | return err; |
442 | } | 444 | } |
@@ -618,10 +620,11 @@ error_inode: | |||
618 | static int msdos_rename(struct inode *old_dir, struct dentry *old_dentry, | 620 | static int msdos_rename(struct inode *old_dir, struct dentry *old_dentry, |
619 | struct inode *new_dir, struct dentry *new_dentry) | 621 | struct inode *new_dir, struct dentry *new_dentry) |
620 | { | 622 | { |
623 | struct super_block *sb = old_dir->i_sb; | ||
621 | unsigned char old_msdos_name[MSDOS_NAME], new_msdos_name[MSDOS_NAME]; | 624 | unsigned char old_msdos_name[MSDOS_NAME], new_msdos_name[MSDOS_NAME]; |
622 | int err, is_hid; | 625 | int err, is_hid; |
623 | 626 | ||
624 | lock_kernel(); | 627 | lock_super(sb); |
625 | 628 | ||
626 | err = msdos_format_name(old_dentry->d_name.name, | 629 | err = msdos_format_name(old_dentry->d_name.name, |
627 | old_dentry->d_name.len, old_msdos_name, | 630 | old_dentry->d_name.len, old_msdos_name, |
@@ -640,9 +643,9 @@ static int msdos_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
640 | err = do_msdos_rename(old_dir, old_msdos_name, old_dentry, | 643 | err = do_msdos_rename(old_dir, old_msdos_name, old_dentry, |
641 | new_dir, new_msdos_name, new_dentry, is_hid); | 644 | new_dir, new_msdos_name, new_dentry, is_hid); |
642 | out: | 645 | out: |
643 | unlock_kernel(); | 646 | unlock_super(sb); |
644 | if (!err) | 647 | if (!err) |
645 | err = fat_flush_inodes(old_dir->i_sb, old_dir, new_dir); | 648 | err = fat_flush_inodes(sb, old_dir, new_dir); |
646 | return err; | 649 | return err; |
647 | } | 650 | } |
648 | 651 | ||
diff --git a/fs/ncpfs/file.c b/fs/ncpfs/file.c index 2b145de45b39..6a7d901f1936 100644 --- a/fs/ncpfs/file.c +++ b/fs/ncpfs/file.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/vmalloc.h> | 19 | #include <linux/vmalloc.h> |
20 | #include <linux/sched.h> | 20 | #include <linux/sched.h> |
21 | #include <linux/smp_lock.h> | ||
21 | 22 | ||
22 | #include <linux/ncp_fs.h> | 23 | #include <linux/ncp_fs.h> |
23 | #include "ncplib_kernel.h" | 24 | #include "ncplib_kernel.h" |
@@ -281,9 +282,18 @@ static int ncp_release(struct inode *inode, struct file *file) { | |||
281 | return 0; | 282 | return 0; |
282 | } | 283 | } |
283 | 284 | ||
285 | static loff_t ncp_remote_llseek(struct file *file, loff_t offset, int origin) | ||
286 | { | ||
287 | loff_t ret; | ||
288 | lock_kernel(); | ||
289 | ret = generic_file_llseek_unlocked(file, offset, origin); | ||
290 | unlock_kernel(); | ||
291 | return ret; | ||
292 | } | ||
293 | |||
284 | const struct file_operations ncp_file_operations = | 294 | const struct file_operations ncp_file_operations = |
285 | { | 295 | { |
286 | .llseek = remote_llseek, | 296 | .llseek = ncp_remote_llseek, |
287 | .read = ncp_file_read, | 297 | .read = ncp_file_read, |
288 | .write = ncp_file_write, | 298 | .write = ncp_file_write, |
289 | .ioctl = ncp_ioctl, | 299 | .ioctl = ncp_ioctl, |
diff --git a/fs/nfs/file.c b/fs/nfs/file.c index d84a3d8f32af..4e98a56a1777 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c | |||
@@ -170,6 +170,7 @@ force_reval: | |||
170 | 170 | ||
171 | static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin) | 171 | static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin) |
172 | { | 172 | { |
173 | loff_t loff; | ||
173 | /* origin == SEEK_END => we must revalidate the cached file length */ | 174 | /* origin == SEEK_END => we must revalidate the cached file length */ |
174 | if (origin == SEEK_END) { | 175 | if (origin == SEEK_END) { |
175 | struct inode *inode = filp->f_mapping->host; | 176 | struct inode *inode = filp->f_mapping->host; |
@@ -177,7 +178,10 @@ static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin) | |||
177 | if (retval < 0) | 178 | if (retval < 0) |
178 | return (loff_t)retval; | 179 | return (loff_t)retval; |
179 | } | 180 | } |
180 | return remote_llseek(filp, offset, origin); | 181 | lock_kernel(); /* BKL needed? */ |
182 | loff = generic_file_llseek_unlocked(filp, offset, origin); | ||
183 | unlock_kernel(); | ||
184 | return loff; | ||
181 | } | 185 | } |
182 | 186 | ||
183 | /* | 187 | /* |
diff --git a/fs/ocfs2/stack_user.c b/fs/ocfs2/stack_user.c index c021280dd462..bd7e0f3acfc7 100644 --- a/fs/ocfs2/stack_user.c +++ b/fs/ocfs2/stack_user.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/fs.h> | 21 | #include <linux/fs.h> |
22 | #include <linux/miscdevice.h> | 22 | #include <linux/miscdevice.h> |
23 | #include <linux/mutex.h> | 23 | #include <linux/mutex.h> |
24 | #include <linux/smp_lock.h> | ||
24 | #include <linux/reboot.h> | 25 | #include <linux/reboot.h> |
25 | #include <asm/uaccess.h> | 26 | #include <asm/uaccess.h> |
26 | 27 | ||
@@ -619,10 +620,12 @@ static int ocfs2_control_open(struct inode *inode, struct file *file) | |||
619 | return -ENOMEM; | 620 | return -ENOMEM; |
620 | p->op_this_node = -1; | 621 | p->op_this_node = -1; |
621 | 622 | ||
623 | lock_kernel(); | ||
622 | mutex_lock(&ocfs2_control_lock); | 624 | mutex_lock(&ocfs2_control_lock); |
623 | file->private_data = p; | 625 | file->private_data = p; |
624 | list_add(&p->op_list, &ocfs2_control_private_list); | 626 | list_add(&p->op_list, &ocfs2_control_private_list); |
625 | mutex_unlock(&ocfs2_control_lock); | 627 | mutex_unlock(&ocfs2_control_lock); |
628 | unlock_kernel(); | ||
626 | 629 | ||
627 | return 0; | 630 | return 0; |
628 | } | 631 | } |
diff --git a/fs/read_write.c b/fs/read_write.c index f0d1240a5c69..9ba495d5a29b 100644 --- a/fs/read_write.c +++ b/fs/read_write.c | |||
@@ -31,12 +31,12 @@ const struct file_operations generic_ro_fops = { | |||
31 | 31 | ||
32 | EXPORT_SYMBOL(generic_ro_fops); | 32 | EXPORT_SYMBOL(generic_ro_fops); |
33 | 33 | ||
34 | loff_t generic_file_llseek(struct file *file, loff_t offset, int origin) | 34 | loff_t |
35 | generic_file_llseek_unlocked(struct file *file, loff_t offset, int origin) | ||
35 | { | 36 | { |
36 | loff_t retval; | 37 | loff_t retval; |
37 | struct inode *inode = file->f_mapping->host; | 38 | struct inode *inode = file->f_mapping->host; |
38 | 39 | ||
39 | mutex_lock(&inode->i_mutex); | ||
40 | switch (origin) { | 40 | switch (origin) { |
41 | case SEEK_END: | 41 | case SEEK_END: |
42 | offset += inode->i_size; | 42 | offset += inode->i_size; |
@@ -46,42 +46,26 @@ loff_t generic_file_llseek(struct file *file, loff_t offset, int origin) | |||
46 | } | 46 | } |
47 | retval = -EINVAL; | 47 | retval = -EINVAL; |
48 | if (offset>=0 && offset<=inode->i_sb->s_maxbytes) { | 48 | if (offset>=0 && offset<=inode->i_sb->s_maxbytes) { |
49 | /* Special lock needed here? */ | ||
49 | if (offset != file->f_pos) { | 50 | if (offset != file->f_pos) { |
50 | file->f_pos = offset; | 51 | file->f_pos = offset; |
51 | file->f_version = 0; | 52 | file->f_version = 0; |
52 | } | 53 | } |
53 | retval = offset; | 54 | retval = offset; |
54 | } | 55 | } |
55 | mutex_unlock(&inode->i_mutex); | ||
56 | return retval; | 56 | return retval; |
57 | } | 57 | } |
58 | EXPORT_SYMBOL(generic_file_llseek_unlocked); | ||
58 | 59 | ||
59 | EXPORT_SYMBOL(generic_file_llseek); | 60 | loff_t generic_file_llseek(struct file *file, loff_t offset, int origin) |
60 | |||
61 | loff_t remote_llseek(struct file *file, loff_t offset, int origin) | ||
62 | { | 61 | { |
63 | loff_t retval; | 62 | loff_t n; |
64 | 63 | mutex_lock(&file->f_dentry->d_inode->i_mutex); | |
65 | lock_kernel(); | 64 | n = generic_file_llseek_unlocked(file, offset, origin); |
66 | switch (origin) { | 65 | mutex_unlock(&file->f_dentry->d_inode->i_mutex); |
67 | case SEEK_END: | 66 | return n; |
68 | offset += i_size_read(file->f_path.dentry->d_inode); | ||
69 | break; | ||
70 | case SEEK_CUR: | ||
71 | offset += file->f_pos; | ||
72 | } | ||
73 | retval = -EINVAL; | ||
74 | if (offset>=0 && offset<=file->f_path.dentry->d_inode->i_sb->s_maxbytes) { | ||
75 | if (offset != file->f_pos) { | ||
76 | file->f_pos = offset; | ||
77 | file->f_version = 0; | ||
78 | } | ||
79 | retval = offset; | ||
80 | } | ||
81 | unlock_kernel(); | ||
82 | return retval; | ||
83 | } | 67 | } |
84 | EXPORT_SYMBOL(remote_llseek); | 68 | EXPORT_SYMBOL(generic_file_llseek); |
85 | 69 | ||
86 | loff_t no_llseek(struct file *file, loff_t offset, int origin) | 70 | loff_t no_llseek(struct file *file, loff_t offset, int origin) |
87 | { | 71 | { |
diff --git a/fs/smbfs/file.c b/fs/smbfs/file.c index efbe29af3d7a..2294783320cb 100644 --- a/fs/smbfs/file.c +++ b/fs/smbfs/file.c | |||
@@ -422,9 +422,18 @@ smb_file_permission(struct inode *inode, int mask, struct nameidata *nd) | |||
422 | return error; | 422 | return error; |
423 | } | 423 | } |
424 | 424 | ||
425 | static loff_t smb_remote_llseek(struct file *file, loff_t offset, int origin) | ||
426 | { | ||
427 | loff_t ret; | ||
428 | lock_kernel(); | ||
429 | ret = generic_file_llseek_unlocked(file, offset, origin); | ||
430 | unlock_kernel(); | ||
431 | return ret; | ||
432 | } | ||
433 | |||
425 | const struct file_operations smb_file_operations = | 434 | const struct file_operations smb_file_operations = |
426 | { | 435 | { |
427 | .llseek = remote_llseek, | 436 | .llseek = smb_remote_llseek, |
428 | .read = do_sync_read, | 437 | .read = do_sync_read, |
429 | .aio_read = smb_file_aio_read, | 438 | .aio_read = smb_file_aio_read, |
430 | .write = do_sync_write, | 439 | .write = do_sync_write, |
diff --git a/fs/vfat/namei.c b/fs/vfat/namei.c index a3522727ea5b..b546ba69be82 100644 --- a/fs/vfat/namei.c +++ b/fs/vfat/namei.c | |||
@@ -645,7 +645,7 @@ static int vfat_add_entry(struct inode *dir, struct qstr *qname, int is_dir, | |||
645 | if (len == 0) | 645 | if (len == 0) |
646 | return -ENOENT; | 646 | return -ENOENT; |
647 | 647 | ||
648 | slots = kmalloc(sizeof(*slots) * MSDOS_SLOTS, GFP_KERNEL); | 648 | slots = kmalloc(sizeof(*slots) * MSDOS_SLOTS, GFP_NOFS); |
649 | if (slots == NULL) | 649 | if (slots == NULL) |
650 | return -ENOMEM; | 650 | return -ENOMEM; |
651 | 651 | ||
@@ -687,7 +687,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, | |||
687 | struct dentry *alias; | 687 | struct dentry *alias; |
688 | int err, table; | 688 | int err, table; |
689 | 689 | ||
690 | lock_kernel(); | 690 | lock_super(sb); |
691 | table = (MSDOS_SB(sb)->options.name_check == 's') ? 2 : 0; | 691 | table = (MSDOS_SB(sb)->options.name_check == 's') ? 2 : 0; |
692 | dentry->d_op = &vfat_dentry_ops[table]; | 692 | dentry->d_op = &vfat_dentry_ops[table]; |
693 | 693 | ||
@@ -699,7 +699,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, | |||
699 | inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos); | 699 | inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos); |
700 | brelse(sinfo.bh); | 700 | brelse(sinfo.bh); |
701 | if (IS_ERR(inode)) { | 701 | if (IS_ERR(inode)) { |
702 | unlock_kernel(); | 702 | unlock_super(sb); |
703 | return ERR_CAST(inode); | 703 | return ERR_CAST(inode); |
704 | } | 704 | } |
705 | alias = d_find_alias(inode); | 705 | alias = d_find_alias(inode); |
@@ -708,13 +708,13 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, | |||
708 | dput(alias); | 708 | dput(alias); |
709 | else { | 709 | else { |
710 | iput(inode); | 710 | iput(inode); |
711 | unlock_kernel(); | 711 | unlock_super(sb); |
712 | return alias; | 712 | return alias; |
713 | } | 713 | } |
714 | 714 | ||
715 | } | 715 | } |
716 | error: | 716 | error: |
717 | unlock_kernel(); | 717 | unlock_super(sb); |
718 | dentry->d_op = &vfat_dentry_ops[table]; | 718 | dentry->d_op = &vfat_dentry_ops[table]; |
719 | dentry->d_time = dentry->d_parent->d_inode->i_version; | 719 | dentry->d_time = dentry->d_parent->d_inode->i_version; |
720 | dentry = d_splice_alias(inode, dentry); | 720 | dentry = d_splice_alias(inode, dentry); |
@@ -734,7 +734,7 @@ static int vfat_create(struct inode *dir, struct dentry *dentry, int mode, | |||
734 | struct timespec ts; | 734 | struct timespec ts; |
735 | int err; | 735 | int err; |
736 | 736 | ||
737 | lock_kernel(); | 737 | lock_super(sb); |
738 | 738 | ||
739 | ts = CURRENT_TIME_SEC; | 739 | ts = CURRENT_TIME_SEC; |
740 | err = vfat_add_entry(dir, &dentry->d_name, 0, 0, &ts, &sinfo); | 740 | err = vfat_add_entry(dir, &dentry->d_name, 0, 0, &ts, &sinfo); |
@@ -755,17 +755,18 @@ static int vfat_create(struct inode *dir, struct dentry *dentry, int mode, | |||
755 | dentry->d_time = dentry->d_parent->d_inode->i_version; | 755 | dentry->d_time = dentry->d_parent->d_inode->i_version; |
756 | d_instantiate(dentry, inode); | 756 | d_instantiate(dentry, inode); |
757 | out: | 757 | out: |
758 | unlock_kernel(); | 758 | unlock_super(sb); |
759 | return err; | 759 | return err; |
760 | } | 760 | } |
761 | 761 | ||
762 | static int vfat_rmdir(struct inode *dir, struct dentry *dentry) | 762 | static int vfat_rmdir(struct inode *dir, struct dentry *dentry) |
763 | { | 763 | { |
764 | struct inode *inode = dentry->d_inode; | 764 | struct inode *inode = dentry->d_inode; |
765 | struct super_block *sb = dir->i_sb; | ||
765 | struct fat_slot_info sinfo; | 766 | struct fat_slot_info sinfo; |
766 | int err; | 767 | int err; |
767 | 768 | ||
768 | lock_kernel(); | 769 | lock_super(sb); |
769 | 770 | ||
770 | err = fat_dir_empty(inode); | 771 | err = fat_dir_empty(inode); |
771 | if (err) | 772 | if (err) |
@@ -783,7 +784,7 @@ static int vfat_rmdir(struct inode *dir, struct dentry *dentry) | |||
783 | inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; | 784 | inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; |
784 | fat_detach(inode); | 785 | fat_detach(inode); |
785 | out: | 786 | out: |
786 | unlock_kernel(); | 787 | unlock_super(sb); |
787 | 788 | ||
788 | return err; | 789 | return err; |
789 | } | 790 | } |
@@ -791,10 +792,11 @@ out: | |||
791 | static int vfat_unlink(struct inode *dir, struct dentry *dentry) | 792 | static int vfat_unlink(struct inode *dir, struct dentry *dentry) |
792 | { | 793 | { |
793 | struct inode *inode = dentry->d_inode; | 794 | struct inode *inode = dentry->d_inode; |
795 | struct super_block *sb = dir->i_sb; | ||
794 | struct fat_slot_info sinfo; | 796 | struct fat_slot_info sinfo; |
795 | int err; | 797 | int err; |
796 | 798 | ||
797 | lock_kernel(); | 799 | lock_super(sb); |
798 | 800 | ||
799 | err = vfat_find(dir, &dentry->d_name, &sinfo); | 801 | err = vfat_find(dir, &dentry->d_name, &sinfo); |
800 | if (err) | 802 | if (err) |
@@ -807,7 +809,7 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry) | |||
807 | inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; | 809 | inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; |
808 | fat_detach(inode); | 810 | fat_detach(inode); |
809 | out: | 811 | out: |
810 | unlock_kernel(); | 812 | unlock_super(sb); |
811 | 813 | ||
812 | return err; | 814 | return err; |
813 | } | 815 | } |
@@ -820,7 +822,7 @@ static int vfat_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
820 | struct timespec ts; | 822 | struct timespec ts; |
821 | int err, cluster; | 823 | int err, cluster; |
822 | 824 | ||
823 | lock_kernel(); | 825 | lock_super(sb); |
824 | 826 | ||
825 | ts = CURRENT_TIME_SEC; | 827 | ts = CURRENT_TIME_SEC; |
826 | cluster = fat_alloc_new_dir(dir, &ts); | 828 | cluster = fat_alloc_new_dir(dir, &ts); |
@@ -849,13 +851,13 @@ static int vfat_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
849 | dentry->d_time = dentry->d_parent->d_inode->i_version; | 851 | dentry->d_time = dentry->d_parent->d_inode->i_version; |
850 | d_instantiate(dentry, inode); | 852 | d_instantiate(dentry, inode); |
851 | 853 | ||
852 | unlock_kernel(); | 854 | unlock_super(sb); |
853 | return 0; | 855 | return 0; |
854 | 856 | ||
855 | out_free: | 857 | out_free: |
856 | fat_free_clusters(dir, cluster); | 858 | fat_free_clusters(dir, cluster); |
857 | out: | 859 | out: |
858 | unlock_kernel(); | 860 | unlock_super(sb); |
859 | return err; | 861 | return err; |
860 | } | 862 | } |
861 | 863 | ||
@@ -869,11 +871,12 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
869 | struct timespec ts; | 871 | struct timespec ts; |
870 | loff_t dotdot_i_pos, new_i_pos; | 872 | loff_t dotdot_i_pos, new_i_pos; |
871 | int err, is_dir, update_dotdot, corrupt = 0; | 873 | int err, is_dir, update_dotdot, corrupt = 0; |
874 | struct super_block *sb = old_dir->i_sb; | ||
872 | 875 | ||
873 | old_sinfo.bh = sinfo.bh = dotdot_bh = NULL; | 876 | old_sinfo.bh = sinfo.bh = dotdot_bh = NULL; |
874 | old_inode = old_dentry->d_inode; | 877 | old_inode = old_dentry->d_inode; |
875 | new_inode = new_dentry->d_inode; | 878 | new_inode = new_dentry->d_inode; |
876 | lock_kernel(); | 879 | lock_super(sb); |
877 | err = vfat_find(old_dir, &old_dentry->d_name, &old_sinfo); | 880 | err = vfat_find(old_dir, &old_dentry->d_name, &old_sinfo); |
878 | if (err) | 881 | if (err) |
879 | goto out; | 882 | goto out; |
@@ -951,7 +954,7 @@ out: | |||
951 | brelse(sinfo.bh); | 954 | brelse(sinfo.bh); |
952 | brelse(dotdot_bh); | 955 | brelse(dotdot_bh); |
953 | brelse(old_sinfo.bh); | 956 | brelse(old_sinfo.bh); |
954 | unlock_kernel(); | 957 | unlock_super(sb); |
955 | 958 | ||
956 | return err; | 959 | return err; |
957 | 960 | ||
diff --git a/include/linux/fs.h b/include/linux/fs.h index d8e2762ed14d..faac13e2cc5c 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -1870,7 +1870,8 @@ extern void | |||
1870 | file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping); | 1870 | file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping); |
1871 | extern loff_t no_llseek(struct file *file, loff_t offset, int origin); | 1871 | extern loff_t no_llseek(struct file *file, loff_t offset, int origin); |
1872 | extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin); | 1872 | extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin); |
1873 | extern loff_t remote_llseek(struct file *file, loff_t offset, int origin); | 1873 | extern loff_t generic_file_llseek_unlocked(struct file *file, loff_t offset, |
1874 | int origin); | ||
1874 | extern int generic_file_open(struct inode * inode, struct file * filp); | 1875 | extern int generic_file_open(struct inode * inode, struct file * filp); |
1875 | extern int nonseekable_open(struct inode * inode, struct file * filp); | 1876 | extern int nonseekable_open(struct inode * inode, struct file * filp); |
1876 | 1877 | ||
diff --git a/include/linux/smp_lock.h b/include/linux/smp_lock.h index aab3a4cff4e1..813be59bf345 100644 --- a/include/linux/smp_lock.h +++ b/include/linux/smp_lock.h | |||
@@ -27,11 +27,24 @@ static inline int reacquire_kernel_lock(struct task_struct *task) | |||
27 | extern void __lockfunc lock_kernel(void) __acquires(kernel_lock); | 27 | extern void __lockfunc lock_kernel(void) __acquires(kernel_lock); |
28 | extern void __lockfunc unlock_kernel(void) __releases(kernel_lock); | 28 | extern void __lockfunc unlock_kernel(void) __releases(kernel_lock); |
29 | 29 | ||
30 | /* | ||
31 | * Various legacy drivers don't really need the BKL in a specific | ||
32 | * function, but they *do* need to know that the BKL became available. | ||
33 | * This function just avoids wrapping a bunch of lock/unlock pairs | ||
34 | * around code which doesn't really need it. | ||
35 | */ | ||
36 | static inline void cycle_kernel_lock(void) | ||
37 | { | ||
38 | lock_kernel(); | ||
39 | unlock_kernel(); | ||
40 | } | ||
41 | |||
30 | #else | 42 | #else |
31 | 43 | ||
32 | #define lock_kernel() do { } while(0) | 44 | #define lock_kernel() do { } while(0) |
33 | #define unlock_kernel() do { } while(0) | 45 | #define unlock_kernel() do { } while(0) |
34 | #define release_kernel_lock(task) do { } while(0) | 46 | #define release_kernel_lock(task) do { } while(0) |
47 | #define cycle_kernel_lock() do { } while(0) | ||
35 | #define reacquire_kernel_lock(task) 0 | 48 | #define reacquire_kernel_lock(task) 0 |
36 | #define kernel_locked() 1 | 49 | #define kernel_locked() 1 |
37 | 50 | ||
diff --git a/kernel/pm_qos_params.c b/kernel/pm_qos_params.c index 0afe32be4c85..8cb757026386 100644 --- a/kernel/pm_qos_params.c +++ b/kernel/pm_qos_params.c | |||
@@ -29,6 +29,7 @@ | |||
29 | 29 | ||
30 | #include <linux/pm_qos_params.h> | 30 | #include <linux/pm_qos_params.h> |
31 | #include <linux/sched.h> | 31 | #include <linux/sched.h> |
32 | #include <linux/smp_lock.h> | ||
32 | #include <linux/spinlock.h> | 33 | #include <linux/spinlock.h> |
33 | #include <linux/slab.h> | 34 | #include <linux/slab.h> |
34 | #include <linux/time.h> | 35 | #include <linux/time.h> |
@@ -358,15 +359,19 @@ static int pm_qos_power_open(struct inode *inode, struct file *filp) | |||
358 | int ret; | 359 | int ret; |
359 | long pm_qos_class; | 360 | long pm_qos_class; |
360 | 361 | ||
362 | lock_kernel(); | ||
361 | pm_qos_class = find_pm_qos_object_by_minor(iminor(inode)); | 363 | pm_qos_class = find_pm_qos_object_by_minor(iminor(inode)); |
362 | if (pm_qos_class >= 0) { | 364 | if (pm_qos_class >= 0) { |
363 | filp->private_data = (void *)pm_qos_class; | 365 | filp->private_data = (void *)pm_qos_class; |
364 | sprintf(name, "process_%d", current->pid); | 366 | sprintf(name, "process_%d", current->pid); |
365 | ret = pm_qos_add_requirement(pm_qos_class, name, | 367 | ret = pm_qos_add_requirement(pm_qos_class, name, |
366 | PM_QOS_DEFAULT_VALUE); | 368 | PM_QOS_DEFAULT_VALUE); |
367 | if (ret >= 0) | 369 | if (ret >= 0) { |
370 | unlock_kernel(); | ||
368 | return 0; | 371 | return 0; |
372 | } | ||
369 | } | 373 | } |
374 | unlock_kernel(); | ||
370 | 375 | ||
371 | return -EPERM; | 376 | return -EPERM; |
372 | } | 377 | } |
diff --git a/net/irda/irnet/irnet.h b/net/irda/irnet/irnet.h index b001c361ad30..bccf4d0059f0 100644 --- a/net/irda/irnet/irnet.h +++ b/net/irda/irnet/irnet.h | |||
@@ -241,6 +241,7 @@ | |||
241 | #include <linux/module.h> | 241 | #include <linux/module.h> |
242 | 242 | ||
243 | #include <linux/kernel.h> | 243 | #include <linux/kernel.h> |
244 | #include <linux/smp_lock.h> | ||
244 | #include <linux/skbuff.h> | 245 | #include <linux/skbuff.h> |
245 | #include <linux/tty.h> | 246 | #include <linux/tty.h> |
246 | #include <linux/proc_fs.h> | 247 | #include <linux/proc_fs.h> |
diff --git a/net/irda/irnet/irnet_ppp.c b/net/irda/irnet/irnet_ppp.c index e0eab5927c4f..e84a70dd346b 100644 --- a/net/irda/irnet/irnet_ppp.c +++ b/net/irda/irnet/irnet_ppp.c | |||
@@ -479,6 +479,7 @@ dev_irnet_open(struct inode * inode, | |||
479 | ap = kzalloc(sizeof(*ap), GFP_KERNEL); | 479 | ap = kzalloc(sizeof(*ap), GFP_KERNEL); |
480 | DABORT(ap == NULL, -ENOMEM, FS_ERROR, "Can't allocate struct irnet...\n"); | 480 | DABORT(ap == NULL, -ENOMEM, FS_ERROR, "Can't allocate struct irnet...\n"); |
481 | 481 | ||
482 | lock_kernel(); | ||
482 | /* initialize the irnet structure */ | 483 | /* initialize the irnet structure */ |
483 | ap->file = file; | 484 | ap->file = file; |
484 | 485 | ||
@@ -500,6 +501,7 @@ dev_irnet_open(struct inode * inode, | |||
500 | { | 501 | { |
501 | DERROR(FS_ERROR, "Can't setup IrDA link...\n"); | 502 | DERROR(FS_ERROR, "Can't setup IrDA link...\n"); |
502 | kfree(ap); | 503 | kfree(ap); |
504 | unlock_kernel(); | ||
503 | return err; | 505 | return err; |
504 | } | 506 | } |
505 | 507 | ||
@@ -510,6 +512,7 @@ dev_irnet_open(struct inode * inode, | |||
510 | file->private_data = ap; | 512 | file->private_data = ap; |
511 | 513 | ||
512 | DEXIT(FS_TRACE, " - ap=0x%p\n", ap); | 514 | DEXIT(FS_TRACE, " - ap=0x%p\n", ap); |
515 | unlock_kernel(); | ||
513 | return 0; | 516 | return 0; |
514 | } | 517 | } |
515 | 518 | ||
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 61f5d425b630..c49b9d9e303c 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/mm.h> | 22 | #include <linux/mm.h> |
23 | #include <linux/file.h> | 23 | #include <linux/file.h> |
24 | #include <linux/slab.h> | 24 | #include <linux/slab.h> |
25 | #include <linux/smp_lock.h> | ||
25 | #include <linux/time.h> | 26 | #include <linux/time.h> |
26 | #include <linux/pm_qos_params.h> | 27 | #include <linux/pm_qos_params.h> |
27 | #include <linux/uio.h> | 28 | #include <linux/uio.h> |
@@ -3249,14 +3250,17 @@ static int snd_pcm_fasync(int fd, struct file * file, int on) | |||
3249 | struct snd_pcm_file * pcm_file; | 3250 | struct snd_pcm_file * pcm_file; |
3250 | struct snd_pcm_substream *substream; | 3251 | struct snd_pcm_substream *substream; |
3251 | struct snd_pcm_runtime *runtime; | 3252 | struct snd_pcm_runtime *runtime; |
3252 | int err; | 3253 | int err = -ENXIO; |
3253 | 3254 | ||
3255 | lock_kernel(); | ||
3254 | pcm_file = file->private_data; | 3256 | pcm_file = file->private_data; |
3255 | substream = pcm_file->substream; | 3257 | substream = pcm_file->substream; |
3256 | snd_assert(substream != NULL, return -ENXIO); | 3258 | snd_assert(substream != NULL, goto out); |
3257 | runtime = substream->runtime; | 3259 | runtime = substream->runtime; |
3258 | 3260 | ||
3259 | err = fasync_helper(fd, file, on, &runtime->fasync); | 3261 | err = fasync_helper(fd, file, on, &runtime->fasync); |
3262 | out: | ||
3263 | unlock_kernel(); | ||
3260 | if (err < 0) | 3264 | if (err < 0) |
3261 | return err; | 3265 | return err; |
3262 | return 0; | 3266 | return 0; |
diff --git a/sound/core/sound.c b/sound/core/sound.c index 09a94953745a..1003ae375d47 100644 --- a/sound/core/sound.c +++ b/sound/core/sound.c | |||
@@ -21,6 +21,7 @@ | |||
21 | 21 | ||
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/slab.h> | 23 | #include <linux/slab.h> |
24 | #include <linux/smp_lock.h> | ||
24 | #include <linux/time.h> | 25 | #include <linux/time.h> |
25 | #include <linux/device.h> | 26 | #include <linux/device.h> |
26 | #include <linux/moduleparam.h> | 27 | #include <linux/moduleparam.h> |
@@ -121,7 +122,7 @@ void *snd_lookup_minor_data(unsigned int minor, int type) | |||
121 | 122 | ||
122 | EXPORT_SYMBOL(snd_lookup_minor_data); | 123 | EXPORT_SYMBOL(snd_lookup_minor_data); |
123 | 124 | ||
124 | static int snd_open(struct inode *inode, struct file *file) | 125 | static int __snd_open(struct inode *inode, struct file *file) |
125 | { | 126 | { |
126 | unsigned int minor = iminor(inode); | 127 | unsigned int minor = iminor(inode); |
127 | struct snd_minor *mptr = NULL; | 128 | struct snd_minor *mptr = NULL; |
@@ -163,6 +164,18 @@ static int snd_open(struct inode *inode, struct file *file) | |||
163 | return err; | 164 | return err; |
164 | } | 165 | } |
165 | 166 | ||
167 | |||
168 | /* BKL pushdown: nasty #ifdef avoidance wrapper */ | ||
169 | static int snd_open(struct inode *inode, struct file *file) | ||
170 | { | ||
171 | int ret; | ||
172 | |||
173 | lock_kernel(); | ||
174 | ret = __snd_open(inode, file); | ||
175 | unlock_kernel(); | ||
176 | return ret; | ||
177 | } | ||
178 | |||
166 | static const struct file_operations snd_fops = | 179 | static const struct file_operations snd_fops = |
167 | { | 180 | { |
168 | .owner = THIS_MODULE, | 181 | .owner = THIS_MODULE, |
diff --git a/sound/sound_core.c b/sound/sound_core.c index 46daca175502..dcfc1d5ce631 100644 --- a/sound/sound_core.c +++ b/sound/sound_core.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/module.h> | 37 | #include <linux/module.h> |
38 | #include <linux/init.h> | 38 | #include <linux/init.h> |
39 | #include <linux/slab.h> | 39 | #include <linux/slab.h> |
40 | #include <linux/smp_lock.h> | ||
40 | #include <linux/types.h> | 41 | #include <linux/types.h> |
41 | #include <linux/kernel.h> | 42 | #include <linux/kernel.h> |
42 | #include <linux/fs.h> | 43 | #include <linux/fs.h> |
@@ -464,6 +465,8 @@ int soundcore_open(struct inode *inode, struct file *file) | |||
464 | struct sound_unit *s; | 465 | struct sound_unit *s; |
465 | const struct file_operations *new_fops = NULL; | 466 | const struct file_operations *new_fops = NULL; |
466 | 467 | ||
468 | lock_kernel (); | ||
469 | |||
467 | chain=unit&0x0F; | 470 | chain=unit&0x0F; |
468 | if(chain==4 || chain==5) /* dsp/audio/dsp16 */ | 471 | if(chain==4 || chain==5) /* dsp/audio/dsp16 */ |
469 | { | 472 | { |
@@ -511,9 +514,11 @@ int soundcore_open(struct inode *inode, struct file *file) | |||
511 | file->f_op = fops_get(old_fops); | 514 | file->f_op = fops_get(old_fops); |
512 | } | 515 | } |
513 | fops_put(old_fops); | 516 | fops_put(old_fops); |
517 | unlock_kernel(); | ||
514 | return err; | 518 | return err; |
515 | } | 519 | } |
516 | spin_unlock(&sound_loader_lock); | 520 | spin_unlock(&sound_loader_lock); |
521 | unlock_kernel(); | ||
517 | return -ENODEV; | 522 | return -ENODEV; |
518 | } | 523 | } |
519 | 524 | ||