Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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
...

+1091 -349
+1
arch/blackfin/mach-bf561/coreb.c
··· 194 194 return ret; 195 195 } 196 196 197 + /* No BKL needed here */ 197 198 static int coreb_open(struct inode *inode, struct file *file) 198 199 { 199 200 spin_lock_irq(&coreb_lock);
+2 -2
arch/cris/arch-v10/drivers/eeprom.c
··· 28 28 #include <linux/init.h> 29 29 #include <linux/delay.h> 30 30 #include <linux/interrupt.h> 31 + #include <linux/smp_lock.h> 31 32 #include <linux/wait.h> 32 33 #include <asm/uaccess.h> 33 34 #include "i2c.h" ··· 376 375 } 377 376 378 377 /* Opens the device. */ 379 - 380 378 static int eeprom_open(struct inode * inode, struct file * file) 381 379 { 382 - 380 + cycle_kernel_lock(); 383 381 if(iminor(inode) != EEPROM_MINOR_NR) 384 382 return -ENXIO; 385 383 if(imajor(inode) != EEPROM_MAJOR_NR)
+3
arch/cris/arch-v10/drivers/gpio.c
··· 16 16 #include <linux/errno.h> 17 17 #include <linux/kernel.h> 18 18 #include <linux/fs.h> 19 + #include <linux/smp_lock.h> 19 20 #include <linux/string.h> 20 21 #include <linux/poll.h> 21 22 #include <linux/init.h> ··· 324 323 if (!priv) 325 324 return -ENOMEM; 326 325 326 + lock_kernel(); 327 327 priv->minor = p; 328 328 329 329 /* initialize the io/alarm struct */ ··· 359 357 alarmlist = priv; 360 358 spin_unlock_irqrestore(&gpio_lock, flags); 361 359 360 + unlock_kernel(); 362 361 return 0; 363 362 } 364 363
+2
arch/cris/arch-v10/drivers/i2c.c
··· 15 15 #include <linux/module.h> 16 16 #include <linux/sched.h> 17 17 #include <linux/slab.h> 18 + #include <linux/smp_lock.h> 18 19 #include <linux/errno.h> 19 20 #include <linux/kernel.h> 20 21 #include <linux/fs.h> ··· 567 566 static int 568 567 i2c_open(struct inode *inode, struct file *filp) 569 568 { 569 + cycle_kernel_lock(); 570 570 return 0; 571 571 } 572 572
+21 -13
arch/cris/arch-v10/drivers/sync_serial.c
··· 21 21 #include <linux/interrupt.h> 22 22 #include <linux/poll.h> 23 23 #include <linux/init.h> 24 + #include <linux/smp_lock.h> 24 25 #include <linux/timer.h> 25 26 #include <asm/irq.h> 26 27 #include <asm/dma.h> ··· 444 443 int dev = MINOR(inode->i_rdev); 445 444 struct sync_port *port; 446 445 int mode; 446 + int err = -EBUSY; 447 447 448 + lock_kernel(); 448 449 DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev)); 449 450 450 451 if (dev < 0 || dev >= NUMBER_OF_PORTS || !ports[dev].enabled) { 451 452 DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev)); 452 - return -ENODEV; 453 + err = -ENODEV; 454 + goto out; 453 455 } 454 456 port = &ports[dev]; 455 457 /* Allow open this device twice (assuming one reader and one writer) */ 456 458 if (port->busy == 2) { 457 459 DEBUG(printk(KERN_DEBUG "Device is busy.. \n")); 458 - return -EBUSY; 460 + goto out; 459 461 } 460 462 if (port->init_irqs) { 461 463 if (port->use_dma) { ··· 469 465 &ports[0])) { 470 466 printk(KERN_CRIT "Can't alloc " 471 467 "sync serial port 1 IRQ"); 472 - return -EBUSY; 468 + goto out; 473 469 } else if (request_irq(25, rx_interrupt, 0, 474 470 "synchronous serial 1 dma rx", 475 471 &ports[0])) { 476 472 free_irq(24, &port[0]); 477 473 printk(KERN_CRIT "Can't alloc " 478 474 "sync serial port 1 IRQ"); 479 - return -EBUSY; 475 + goto out; 480 476 } else if (cris_request_dma(8, 481 477 "synchronous serial 1 dma tr", 482 478 DMA_VERBOSE_ON_ERROR, ··· 486 482 printk(KERN_CRIT "Can't alloc " 487 483 "sync serial port 1 " 488 484 "TX DMA channel"); 489 - return -EBUSY; 485 + goto out; 490 486 } else if (cris_request_dma(9, 491 487 "synchronous serial 1 dma rec", 492 488 DMA_VERBOSE_ON_ERROR, ··· 497 493 printk(KERN_CRIT "Can't alloc " 498 494 "sync serial port 1 " 499 495 "RX DMA channel"); 500 - return -EBUSY; 496 + goto out; 501 497 } 502 498 #endif 503 499 RESET_DMA(8); WAIT_DMA(8); ··· 524 520 &ports[1])) { 525 521 printk(KERN_CRIT "Can't alloc " 526 522 "sync serial port 3 IRQ"); 527 - return -EBUSY; 523 + goto out; 528 524 } else if (request_irq(21, rx_interrupt, 0, 529 525 "synchronous serial 3 dma rx", 530 526 &ports[1])) { 531 527 free_irq(20, &ports[1]); 532 528 printk(KERN_CRIT "Can't alloc " 533 529 "sync serial port 3 IRQ"); 534 - return -EBUSY; 530 + goto out; 535 531 } else if (cris_request_dma(4, 536 532 "synchronous serial 3 dma tr", 537 533 DMA_VERBOSE_ON_ERROR, ··· 541 537 printk(KERN_CRIT "Can't alloc " 542 538 "sync serial port 3 " 543 539 "TX DMA channel"); 544 - return -EBUSY; 540 + goto out; 545 541 } else if (cris_request_dma(5, 546 542 "synchronous serial 3 dma rec", 547 543 DMA_VERBOSE_ON_ERROR, ··· 552 548 printk(KERN_CRIT "Can't alloc " 553 549 "sync serial port 3 " 554 550 "RX DMA channel"); 555 - return -EBUSY; 551 + goto out; 556 552 } 557 553 #endif 558 554 RESET_DMA(4); WAIT_DMA(4); ··· 585 581 &ports[0])) { 586 582 printk(KERN_CRIT "Can't alloc " 587 583 "sync serial manual irq"); 588 - return -EBUSY; 584 + goto out; 589 585 } 590 586 } else if (port == &ports[1]) { 591 587 if (request_irq(8, ··· 595 591 &ports[1])) { 596 592 printk(KERN_CRIT "Can't alloc " 597 593 "sync serial manual irq"); 598 - return -EBUSY; 594 + goto out; 599 595 } 600 596 } 601 597 port->init_irqs = 0; ··· 624 620 *R_IRQ_MASK1_SET = 1 << port->data_avail_bit; 625 621 DEBUG(printk(KERN_DEBUG "sser%d rec started\n", dev)); 626 622 } 627 - return 0; 623 + ret = 0; 624 + 625 + out: 626 + unlock_kernel(); 627 + return ret; 628 628 } 629 629 630 630 static int sync_serial_release(struct inode *inode, struct file *file)
+2 -1
arch/cris/arch-v32/drivers/cryptocop.c
··· 11 11 #include <linux/string.h> 12 12 #include <linux/fs.h> 13 13 #include <linux/mm.h> 14 + #include <linux/smp_lock.h> 14 15 #include <linux/spinlock.h> 15 16 #include <linux/stddef.h> 16 17 ··· 2303 2302 return 0; 2304 2303 } 2305 2304 2306 - 2307 2305 static int cryptocop_open(struct inode *inode, struct file *filp) 2308 2306 { 2309 2307 int p = iminor(inode); 2310 2308 2309 + cycle_kernel_lock(); 2311 2310 if (p != CRYPTOCOP_MINOR) return -EINVAL; 2312 2311 2313 2312 filp->private_data = NULL;
+2
arch/cris/arch-v32/drivers/i2c.c
··· 33 33 #include <linux/fs.h> 34 34 #include <linux/string.h> 35 35 #include <linux/init.h> 36 + #include <linux/smp_lock.h> 36 37 37 38 #include <asm/etraxi2c.h> 38 39 ··· 637 636 static int 638 637 i2c_open(struct inode *inode, struct file *filp) 639 638 { 639 + cycle_kernel_lock(); 640 640 return 0; 641 641 } 642 642
+4
arch/cris/arch-v32/drivers/mach-a3/gpio.c
··· 23 23 #include <linux/init.h> 24 24 #include <linux/interrupt.h> 25 25 #include <linux/spinlock.h> 26 + #include <linux/smp_lock.h> 26 27 27 28 #include <asm/etraxgpio.h> 28 29 #include <hwregs/reg_map.h> ··· 391 390 392 391 if (!priv) 393 392 return -ENOMEM; 393 + 394 + lock_kernel(); 394 395 memset(priv, 0, sizeof(*priv)); 395 396 396 397 priv->minor = p; ··· 415 412 spin_unlock_irq(&gpio_lock); 416 413 } 417 414 415 + unlock_kernel(); 418 416 return 0; 419 417 } 420 418
+4 -1
arch/cris/arch-v32/drivers/mach-fs/gpio.c
··· 22 22 #include <linux/init.h> 23 23 #include <linux/interrupt.h> 24 24 #include <linux/spinlock.h> 25 + #include <linux/smp_lock.h> 25 26 26 27 #include <asm/etraxgpio.h> 27 28 #include <hwregs/reg_map.h> ··· 427 426 return -EINVAL; 428 427 429 428 priv = kmalloc(sizeof(struct gpio_private), GFP_KERNEL); 430 - 431 429 if (!priv) 432 430 return -ENOMEM; 431 + 432 + lock_kernel(); 433 433 memset(priv, 0, sizeof(*priv)); 434 434 435 435 priv->minor = p; ··· 451 449 alarmlist = priv; 452 450 spin_unlock_irq(&alarm_lock); 453 451 452 + unlock_kernel(); 454 453 return 0; 455 454 } 456 455
+20 -13
arch/cris/arch-v32/drivers/sync_serial.c
··· 14 14 #include <linux/major.h> 15 15 #include <linux/sched.h> 16 16 #include <linux/slab.h> 17 + #include <linux/smp_lock.h> 17 18 #include <linux/interrupt.h> 18 19 #include <linux/poll.h> 19 20 #include <linux/init.h> ··· 430 429 static int sync_serial_open(struct inode *inode, struct file *file) 431 430 { 432 431 int dev = iminor(inode); 432 + int ret = -EBUSY; 433 433 sync_port *port; 434 434 reg_dma_rw_cfg cfg = {.en = regk_dma_yes}; 435 435 reg_dma_rw_intr_mask intr_mask = {.data = regk_dma_yes}; 436 436 437 + lock_kernel(); 437 438 DEBUG(printk(KERN_DEBUG "Open sync serial port %d\n", dev)); 438 439 439 440 if (dev < 0 || dev >= NBR_PORTS || !ports[dev].enabled) 440 441 { 441 442 DEBUG(printk(KERN_DEBUG "Invalid minor %d\n", dev)); 442 - return -ENODEV; 443 + ret = -ENODEV; 444 + goto out; 443 445 } 444 446 port = &ports[dev]; 445 447 /* Allow open this device twice (assuming one reader and one writer) */ 446 448 if (port->busy == 2) 447 449 { 448 450 DEBUG(printk(KERN_DEBUG "Device is busy.. \n")); 449 - return -EBUSY; 451 + goto out; 450 452 } 451 453 452 454 ··· 463 459 "synchronous serial 0 dma tr", 464 460 &ports[0])) { 465 461 printk(KERN_CRIT "Can't allocate sync serial port 0 IRQ"); 466 - return -EBUSY; 462 + goto out; 467 463 } else if (request_irq(DMA_IN_INTR_VECT, 468 464 rx_interrupt, 469 465 0, ··· 471 467 &ports[0])) { 472 468 free_irq(DMA_OUT_INTR_VECT, &port[0]); 473 469 printk(KERN_CRIT "Can't allocate sync serial port 0 IRQ"); 474 - return -EBUSY; 470 + goto out; 475 471 } else if (crisv32_request_dma(OUT_DMA_NBR, 476 472 "synchronous serial 0 dma tr", 477 473 DMA_VERBOSE_ON_ERROR, ··· 480 476 free_irq(DMA_OUT_INTR_VECT, &port[0]); 481 477 free_irq(DMA_IN_INTR_VECT, &port[0]); 482 478 printk(KERN_CRIT "Can't allocate sync serial port 0 TX DMA channel"); 483 - return -EBUSY; 479 + goto out; 484 480 } else if (crisv32_request_dma(IN_DMA_NBR, 485 481 "synchronous serial 0 dma rec", 486 482 DMA_VERBOSE_ON_ERROR, ··· 490 486 free_irq(DMA_OUT_INTR_VECT, &port[0]); 491 487 free_irq(DMA_IN_INTR_VECT, &port[0]); 492 488 printk(KERN_CRIT "Can't allocate sync serial port 1 RX DMA channel"); 493 - return -EBUSY; 489 + goto out; 494 490 } 495 491 #endif 496 492 } ··· 503 499 "synchronous serial 1 dma tr", 504 500 &ports[1])) { 505 501 printk(KERN_CRIT "Can't allocate sync serial port 1 IRQ"); 506 - return -EBUSY; 502 + goto out; 507 503 } else if (request_irq(DMA7_INTR_VECT, 508 504 rx_interrupt, 509 505 0, ··· 511 507 &ports[1])) { 512 508 free_irq(DMA6_INTR_VECT, &ports[1]); 513 509 printk(KERN_CRIT "Can't allocate sync serial port 3 IRQ"); 514 - return -EBUSY; 510 + goto out; 515 511 } else if (crisv32_request_dma( 516 512 SYNC_SER1_TX_DMA_NBR, 517 513 "synchronous serial 1 dma tr", ··· 521 517 free_irq(DMA6_INTR_VECT, &ports[1]); 522 518 free_irq(DMA7_INTR_VECT, &ports[1]); 523 519 printk(KERN_CRIT "Can't allocate sync serial port 3 TX DMA channel"); 524 - return -EBUSY; 520 + goto out; 525 521 } else if (crisv32_request_dma( 526 522 SYNC_SER1_RX_DMA_NBR, 527 523 "synchronous serial 3 dma rec", ··· 532 528 free_irq(DMA6_INTR_VECT, &ports[1]); 533 529 free_irq(DMA7_INTR_VECT, &ports[1]); 534 530 printk(KERN_CRIT "Can't allocate sync serial port 3 RX DMA channel"); 535 - return -EBUSY; 531 + goto out; 536 532 } 537 533 #endif 538 534 } ··· 558 554 "synchronous serial manual irq", 559 555 &ports[0])) { 560 556 printk("Can't allocate sync serial manual irq"); 561 - return -EBUSY; 557 + goto out; 562 558 } 563 559 } 564 560 #ifdef CONFIG_ETRAXFS ··· 569 565 "synchronous serial manual irq", 570 566 &ports[1])) { 571 567 printk(KERN_CRIT "Can't allocate sync serial manual irq"); 572 - return -EBUSY; 568 + goto out; 573 569 } 574 570 } 575 571 #endif ··· 582 578 } /* port->init_irqs */ 583 579 584 580 port->busy++; 585 - return 0; 581 + ret = 0; 582 + out: 583 + unlock_kernel(); 584 + return ret; 586 585 } 587 586 588 587 static int sync_serial_release(struct inode *inode, struct file *file)
+6 -1
arch/m68k/bvme6000/rtc.c
··· 10 10 #include <linux/errno.h> 11 11 #include <linux/miscdevice.h> 12 12 #include <linux/slab.h> 13 + #include <linux/smp_lock.h> 13 14 #include <linux/ioport.h> 14 15 #include <linux/capability.h> 15 16 #include <linux/fcntl.h> ··· 141 140 142 141 static int rtc_open(struct inode *inode, struct file *file) 143 142 { 144 - if(rtc_status) 143 + lock_kernel(); 144 + if(rtc_status) { 145 + unlock_kernel(); 145 146 return -EBUSY; 147 + } 146 148 147 149 rtc_status = 1; 150 + unlock_kernel(); 148 151 return 0; 149 152 } 150 153
+4
arch/m68k/mvme16x/rtc.c
··· 10 10 #include <linux/errno.h> 11 11 #include <linux/miscdevice.h> 12 12 #include <linux/slab.h> 13 + #include <linux/smp_lock.h> 13 14 #include <linux/ioport.h> 14 15 #include <linux/capability.h> 15 16 #include <linux/fcntl.h> ··· 128 127 129 128 static int rtc_open(struct inode *inode, struct file *file) 130 129 { 130 + lock_kernel(); 131 131 if( !atomic_dec_and_test(&rtc_ready) ) 132 132 { 133 133 atomic_inc( &rtc_ready ); 134 + unlock_kernel(); 134 135 return -EBUSY; 135 136 } 137 + unlock_kernel(); 136 138 137 139 return 0; 138 140 }
+8 -1
arch/mips/basler/excite/excite_iodev.c
··· 26 26 #include <linux/interrupt.h> 27 27 #include <linux/platform_device.h> 28 28 #include <linux/miscdevice.h> 29 + #include <linux/smp_lock.h> 29 30 30 31 #include "excite_iodev.h" 31 32 ··· 111 110 112 111 static int iodev_open(struct inode *i, struct file *f) 113 112 { 114 - return request_irq(iodev_irq, iodev_irqhdl, IRQF_DISABLED, 113 + int ret; 114 + 115 + lock_kernel(); 116 + ret = request_irq(iodev_irq, iodev_irqhdl, IRQF_DISABLED, 115 117 iodev_name, &miscdev); 118 + unlock_kernel(); 119 + 120 + return ret; 116 121 } 117 122 118 123 static int iodev_release(struct inode *i, struct file *f)
+6 -1
arch/mips/kernel/rtlx.c
··· 28 28 #include <linux/vmalloc.h> 29 29 #include <linux/elf.h> 30 30 #include <linux/seq_file.h> 31 + #include <linux/smp_lock.h> 31 32 #include <linux/syscalls.h> 32 33 #include <linux/moduleloader.h> 33 34 #include <linux/interrupt.h> ··· 393 392 static int file_open(struct inode *inode, struct file *filp) 394 393 { 395 394 int minor = iminor(inode); 395 + int err; 396 396 397 - return rtlx_open(minor, (filp->f_flags & O_NONBLOCK) ? 0 : 1); 397 + lock_kernel(); 398 + err = rtlx_open(minor, (filp->f_flags & O_NONBLOCK) ? 0 : 1); 399 + unlock_kernel(); 400 + return err; 398 401 } 399 402 400 403 static int file_release(struct inode *inode, struct file *filp)
+9 -3
arch/mips/kernel/vpe.c
··· 38 38 #include <linux/vmalloc.h> 39 39 #include <linux/elf.h> 40 40 #include <linux/seq_file.h> 41 + #include <linux/smp_lock.h> 41 42 #include <linux/syscalls.h> 42 43 #include <linux/moduleloader.h> 43 44 #include <linux/interrupt.h> ··· 1051 1050 enum vpe_state state; 1052 1051 struct vpe_notifications *not; 1053 1052 struct vpe *v; 1054 - int ret; 1053 + int ret, err = 0; 1055 1054 1055 + lock_kernel(); 1056 1056 if (minor != iminor(inode)) { 1057 1057 /* assume only 1 device at the moment. */ 1058 1058 printk(KERN_WARNING "VPE loader: only vpe1 is supported\n"); 1059 - return -ENODEV; 1059 + err = -ENODEV; 1060 + goto out; 1060 1061 } 1061 1062 1062 1063 if ((v = get_vpe(tclimit)) == NULL) { 1063 1064 printk(KERN_WARNING "VPE loader: unable to get vpe\n"); 1064 - return -ENODEV; 1065 + err = -ENODEV; 1066 + goto out; 1065 1067 } 1066 1068 1067 1069 state = xchg(&v->state, VPE_STATE_INUSE); ··· 1104 1100 v->shared_ptr = NULL; 1105 1101 v->__start = 0; 1106 1102 1103 + out: 1104 + unlock_kernel(); 1107 1105 return 0; 1108 1106 } 1109 1107
+18 -7
arch/mips/sibyte/common/sb_tbprof.c
··· 28 28 #include <linux/init.h> 29 29 #include <linux/interrupt.h> 30 30 #include <linux/slab.h> 31 + #include <linux/smp_lock.h> 31 32 #include <linux/vmalloc.h> 32 33 #include <linux/fs.h> 33 34 #include <linux/errno.h> ··· 403 402 static int sbprof_tb_open(struct inode *inode, struct file *filp) 404 403 { 405 404 int minor; 405 + int err = 0; 406 406 407 + lock_kernel(); 407 408 minor = iminor(inode); 408 - if (minor != 0) 409 - return -ENODEV; 409 + if (minor != 0) { 410 + err = -ENODEV; 411 + goto out; 412 + } 410 413 411 - if (xchg(&sbp.open, SB_OPENING) != SB_CLOSED) 412 - return -EBUSY; 414 + if (xchg(&sbp.open, SB_OPENING) != SB_CLOSED) { 415 + err = -EBUSY; 416 + goto out; 417 + } 413 418 414 419 memset(&sbp, 0, sizeof(struct sbprof_tb)); 415 420 sbp.sbprof_tbbuf = vmalloc(MAX_TBSAMPLE_BYTES); 416 - if (!sbp.sbprof_tbbuf) 417 - return -ENOMEM; 421 + if (!sbp.sbprof_tbbuf) { 422 + err = -ENOMEM; 423 + goto out; 424 + } 418 425 memset(sbp.sbprof_tbbuf, 0, MAX_TBSAMPLE_BYTES); 419 426 init_waitqueue_head(&sbp.tb_sync); 420 427 init_waitqueue_head(&sbp.tb_read); ··· 430 421 431 422 sbp.open = SB_OPEN; 432 423 433 - return 0; 424 + out: 425 + unlock_kernel(); 426 + return err; 434 427 } 435 428 436 429 static int sbprof_tb_release(struct inode *inode, struct file *filp)
+4
arch/parisc/kernel/perf.c
··· 46 46 #include <linux/init.h> 47 47 #include <linux/proc_fs.h> 48 48 #include <linux/miscdevice.h> 49 + #include <linux/smp_lock.h> 49 50 #include <linux/spinlock.h> 50 51 51 52 #include <asm/uaccess.h> ··· 261 260 */ 262 261 static int perf_open(struct inode *inode, struct file *file) 263 262 { 263 + lock_kernel(); 264 264 spin_lock(&perf_lock); 265 265 if (perf_enabled) { 266 266 spin_unlock(&perf_lock); 267 + unlock_kernel(); 267 268 return -EBUSY; 268 269 } 269 270 perf_enabled = 1; 270 271 spin_unlock(&perf_lock); 272 + unlock_kernel(); 271 273 272 274 return 0; 273 275 }
+2
arch/s390/crypto/prng.c
··· 6 6 #include <linux/fs.h> 7 7 #include <linux/init.h> 8 8 #include <linux/kernel.h> 9 + #include <linux/smp_lock.h> 9 10 #include <linux/miscdevice.h> 10 11 #include <linux/module.h> 11 12 #include <linux/moduleparam.h> ··· 49 48 50 49 static int prng_open(struct inode *inode, struct file *file) 51 50 { 51 + cycle_kernel_lock(); 52 52 return nonseekable_open(inode, file); 53 53 } 54 54
+7 -3
arch/sh/boards/landisk/gio.c
··· 14 14 */ 15 15 #include <linux/module.h> 16 16 #include <linux/init.h> 17 + #include <linux/smp_lock.h> 17 18 #include <linux/kdev_t.h> 18 19 #include <linux/cdev.h> 19 20 #include <linux/fs.h> ··· 33 32 static int gio_open(struct inode *inode, struct file *filp) 34 33 { 35 34 int minor; 35 + int ret = -ENOENT; 36 36 37 + lock_kernel(); 37 38 minor = MINOR(inode->i_rdev); 38 39 if (minor < DEVCOUNT) { 39 40 if (openCnt > 0) { 40 - return -EALREADY; 41 + ret = -EALREADY; 41 42 } else { 42 43 openCnt++; 43 - return 0; 44 + ret = 0; 44 45 } 45 46 } 46 - return -ENOENT; 47 + unlock_kernel(); 48 + return ret; 47 49 } 48 50 49 51 static int gio_close(struct inode *inode, struct file *filp)
+2
arch/sparc/kernel/apc.c
··· 10 10 #include <linux/errno.h> 11 11 #include <linux/init.h> 12 12 #include <linux/miscdevice.h> 13 + #include <linux/smp_lock.h> 13 14 #include <linux/pm.h> 14 15 15 16 #include <asm/io.h> ··· 76 75 77 76 static int apc_open(struct inode *inode, struct file *f) 78 77 { 78 + cycle_kernel_lock(); 79 79 return 0; 80 80 } 81 81
+6 -1
arch/sparc64/kernel/time.c
··· 11 11 #include <linux/errno.h> 12 12 #include <linux/module.h> 13 13 #include <linux/sched.h> 14 + #include <linux/smp_lock.h> 14 15 #include <linux/kernel.h> 15 16 #include <linux/param.h> 16 17 #include <linux/string.h> ··· 1660 1659 1661 1660 static int mini_rtc_open(struct inode *inode, struct file *file) 1662 1661 { 1663 - if (mini_rtc_status & RTC_IS_OPEN) 1662 + lock_kernel(); 1663 + if (mini_rtc_status & RTC_IS_OPEN) { 1664 + unlock_kernel(); 1664 1665 return -EBUSY; 1666 + } 1665 1667 1666 1668 mini_rtc_status |= RTC_IS_OPEN; 1669 + unlock_kernel(); 1667 1670 1668 1671 return 0; 1669 1672 }
+3
arch/um/drivers/harddog_kern.c
··· 66 66 int err = -EBUSY; 67 67 char *sock = NULL; 68 68 69 + lock_kernel(); 69 70 spin_lock(&lock); 70 71 if(timer_alive) 71 72 goto err; ··· 83 82 84 83 timer_alive = 1; 85 84 spin_unlock(&lock); 85 + unlock_kernel(); 86 86 return nonseekable_open(inode, file); 87 87 err: 88 88 spin_unlock(&lock); 89 + unlock_kernel(); 89 90 return err; 90 91 } 91 92
+2
arch/um/drivers/mmapper_kern.c
··· 16 16 #include <linux/miscdevice.h> 17 17 #include <linux/module.h> 18 18 #include <linux/mm.h> 19 + #include <linux/smp_lock.h> 19 20 #include <asm/uaccess.h> 20 21 #include "mem_user.h" 21 22 ··· 78 77 79 78 static int mmapper_open(struct inode *inode, struct file *file) 80 79 { 80 + cycle_kernel_lock(); 81 81 return 0; 82 82 } 83 83
+3
arch/um/drivers/random.c
··· 7 7 * of the GNU General Public License, incorporated herein by reference. 8 8 */ 9 9 #include <linux/sched.h> 10 + #include <linux/smp_lock.h> 10 11 #include <linux/module.h> 11 12 #include <linux/fs.h> 12 13 #include <linux/interrupt.h> ··· 34 33 35 34 static int rng_dev_open (struct inode *inode, struct file *filp) 36 35 { 36 + cycle_kernel_lock(); 37 + 37 38 /* enforce read-only access to this chrdev */ 38 39 if ((filp->f_mode & FMODE_READ) == 0) 39 40 return -EINVAL;
+4
arch/x86/kernel/apm_32.c
··· 204 204 #include <linux/module.h> 205 205 206 206 #include <linux/poll.h> 207 + #include <linux/smp_lock.h> 207 208 #include <linux/types.h> 208 209 #include <linux/stddef.h> 209 210 #include <linux/timer.h> ··· 1550 1549 { 1551 1550 struct apm_user *as; 1552 1551 1552 + lock_kernel(); 1553 1553 as = kmalloc(sizeof(*as), GFP_KERNEL); 1554 1554 if (as == NULL) { 1555 1555 printk(KERN_ERR "apm: cannot allocate struct of size %d bytes\n", 1556 1556 sizeof(*as)); 1557 + unlock_kernel(); 1557 1558 return -ENOMEM; 1558 1559 } 1559 1560 as->magic = APM_BIOS_MAGIC; ··· 1577 1574 user_list = as; 1578 1575 spin_unlock(&user_list_lock); 1579 1576 filp->private_data = as; 1577 + unlock_kernel(); 1580 1578 return 0; 1581 1579 } 1582 1580
+4
arch/x86/kernel/cpu/mcheck/mce_64.c
··· 9 9 #include <linux/types.h> 10 10 #include <linux/kernel.h> 11 11 #include <linux/sched.h> 12 + #include <linux/smp_lock.h> 12 13 #include <linux/string.h> 13 14 #include <linux/rcupdate.h> 14 15 #include <linux/kallsyms.h> ··· 533 532 534 533 static int mce_open(struct inode *inode, struct file *file) 535 534 { 535 + lock_kernel(); 536 536 spin_lock(&mce_state_lock); 537 537 538 538 if (open_exclu || (open_count && (file->f_flags & O_EXCL))) { 539 539 spin_unlock(&mce_state_lock); 540 + unlock_kernel(); 540 541 return -EBUSY; 541 542 } 542 543 ··· 547 544 open_count++; 548 545 549 546 spin_unlock(&mce_state_lock); 547 + unlock_kernel(); 550 548 551 549 return nonseekable_open(inode, file); 552 550 }
+16 -7
arch/x86/kernel/cpuid.c
··· 33 33 #include <linux/init.h> 34 34 #include <linux/poll.h> 35 35 #include <linux/smp.h> 36 + #include <linux/smp_lock.h> 36 37 #include <linux/major.h> 37 38 #include <linux/fs.h> 38 39 #include <linux/smp_lock.h> ··· 108 107 109 108 static int cpuid_open(struct inode *inode, struct file *file) 110 109 { 111 - unsigned int cpu = iminor(file->f_path.dentry->d_inode); 112 - struct cpuinfo_x86 *c = &cpu_data(cpu); 110 + unsigned int cpu; 111 + struct cpuinfo_x86 *c; 112 + int ret = 0; 113 + 114 + lock_kernel(); 113 115 114 - if (cpu >= NR_CPUS || !cpu_online(cpu)) 115 - return -ENXIO; /* No such CPU */ 116 + cpu = iminor(file->f_path.dentry->d_inode); 117 + if (cpu >= NR_CPUS || !cpu_online(cpu)) { 118 + ret = -ENXIO; /* No such CPU */ 119 + goto out; 120 + } 121 + c = &cpu_data(cpu); 116 122 if (c->cpuid_level < 0) 117 - return -EIO; /* CPUID not supported */ 118 - 119 - return 0; 123 + ret = -EIO; /* CPUID not supported */ 124 + out: 125 + unlock_kernel(); 126 + return ret; 120 127 } 121 128 122 129 /*
+2
arch/x86/kernel/microcode.c
··· 76 76 #include <linux/kernel.h> 77 77 #include <linux/init.h> 78 78 #include <linux/sched.h> 79 + #include <linux/smp_lock.h> 79 80 #include <linux/cpumask.h> 80 81 #include <linux/module.h> 81 82 #include <linux/slab.h> ··· 424 423 425 424 static int microcode_open (struct inode *unused1, struct file *unused2) 426 425 { 426 + cycle_kernel_lock(); 427 427 return capable(CAP_SYS_RAWIO) ? 0 : -EPERM; 428 428 } 429 429
+12 -4
arch/x86/kernel/msr.c
··· 117 117 { 118 118 unsigned int cpu = iminor(file->f_path.dentry->d_inode); 119 119 struct cpuinfo_x86 *c = &cpu_data(cpu); 120 + int ret = 0; 120 121 121 - if (cpu >= NR_CPUS || !cpu_online(cpu)) 122 - return -ENXIO; /* No such CPU */ 122 + lock_kernel(); 123 + cpu = iminor(file->f_path.dentry->d_inode); 124 + 125 + if (cpu >= NR_CPUS || !cpu_online(cpu)) { 126 + ret = -ENXIO; /* No such CPU */ 127 + goto out; 128 + } 129 + c = &cpu_data(cpu); 123 130 if (!cpu_has(c, X86_FEATURE_MSR)) 124 - return -EIO; /* MSR not supported */ 125 - 131 + ret = -EIO; /* MSR not supported */ 132 + out: 133 + unlock_kernel(); 126 134 return 0; 127 135 } 128 136
+6 -1
block/bsg.c
··· 19 19 #include <linux/uio.h> 20 20 #include <linux/idr.h> 21 21 #include <linux/bsg.h> 22 + #include <linux/smp_lock.h> 22 23 23 24 #include <scsi/scsi.h> 24 25 #include <scsi/scsi_ioctl.h> ··· 852 851 853 852 static int bsg_open(struct inode *inode, struct file *file) 854 853 { 855 - struct bsg_device *bd = bsg_get_device(inode, file); 854 + struct bsg_device *bd; 855 + 856 + lock_kernel(); 857 + bd = bsg_get_device(inode, file); 858 + unlock_kernel(); 856 859 857 860 if (IS_ERR(bd)) 858 861 return PTR_ERR(bd);
+6 -1
drivers/block/aoe/aoechr.c
··· 7 7 #include <linux/hdreg.h> 8 8 #include <linux/blkdev.h> 9 9 #include <linux/delay.h> 10 + #include <linux/smp_lock.h> 10 11 #include "aoe.h" 11 12 12 13 enum { ··· 175 174 { 176 175 int n, i; 177 176 177 + lock_kernel(); 178 178 n = iminor(inode); 179 179 filp->private_data = (void *) (unsigned long) n; 180 180 181 181 for (i = 0; i < ARRAY_SIZE(chardevs); ++i) 182 - if (chardevs[i].minor == n) 182 + if (chardevs[i].minor == n) { 183 + unlock_kernel(); 183 184 return 0; 185 + } 186 + unlock_kernel(); 184 187 return -EINVAL; 185 188 } 186 189
+16 -6
drivers/block/paride/pg.c
··· 162 162 #include <linux/pg.h> 163 163 #include <linux/device.h> 164 164 #include <linux/sched.h> /* current, TASK_* */ 165 + #include <linux/smp_lock.h> 165 166 #include <linux/jiffies.h> 166 167 167 168 #include <asm/uaccess.h> ··· 516 515 { 517 516 int unit = iminor(inode) & 0x7f; 518 517 struct pg *dev = &devices[unit]; 518 + int ret = 0; 519 519 520 - if ((unit >= PG_UNITS) || (!dev->present)) 521 - return -ENODEV; 520 + lock_kernel(); 521 + if ((unit >= PG_UNITS) || (!dev->present)) { 522 + ret = -ENODEV; 523 + goto out; 524 + } 522 525 523 - if (test_and_set_bit(0, &dev->access)) 524 - return -EBUSY; 526 + if (test_and_set_bit(0, &dev->access)) { 527 + ret = -EBUSY; 528 + goto out; 529 + } 525 530 526 531 if (dev->busy) { 527 532 pg_reset(dev); ··· 540 533 if (dev->bufptr == NULL) { 541 534 clear_bit(0, &dev->access); 542 535 printk("%s: buffer allocation failed\n", dev->name); 543 - return -ENOMEM; 536 + ret = -ENOMEM; 537 + goto out; 544 538 } 545 539 546 540 file->private_data = dev; 547 541 548 - return 0; 542 + out: 543 + unlock_kernel(); 544 + return ret; 549 545 } 550 546 551 547 static int pg_release(struct inode *inode, struct file *file)
+6 -1
drivers/block/paride/pt.c
··· 650 650 struct pt_unit *tape = pt + unit; 651 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 656 return -ENODEV; 657 + } 655 658 656 659 err = -EBUSY; 657 660 if (!atomic_dec_and_test(&tape->available)) ··· 681 678 } 682 679 683 680 file->private_data = tape; 681 + unlock_kernel(); 684 682 return 0; 685 683 686 684 out: 687 685 atomic_inc(&tape->available); 686 + unlock_kernel(); 688 687 return err; 689 688 } 690 689
+11 -3
drivers/bluetooth/hci_vhci.c
··· 28 28 #include <linux/kernel.h> 29 29 #include <linux/init.h> 30 30 #include <linux/slab.h> 31 + #include <linux/smp_lock.h> 31 32 #include <linux/types.h> 32 33 #include <linux/errno.h> 33 34 #include <linux/sched.h> ··· 264 263 skb_queue_head_init(&data->readq); 265 264 init_waitqueue_head(&data->read_wait); 266 265 266 + lock_kernel(); 267 267 hdev = hci_alloc_dev(); 268 268 if (!hdev) { 269 269 kfree(data); 270 + unlock_kernel(); 270 271 return -ENOMEM; 271 272 } 272 273 ··· 289 286 BT_ERR("Can't register HCI device"); 290 287 kfree(data); 291 288 hci_free_dev(hdev); 289 + unlock_kernel(); 292 290 return -EBUSY; 293 291 } 294 292 295 293 file->private_data = data; 294 + unlock_kernel(); 296 295 297 296 return nonseekable_open(inode, file); 298 297 } ··· 318 313 static int vhci_fasync(int fd, struct file *file, int on) 319 314 { 320 315 struct vhci_data *data = file->private_data; 321 - int err; 316 + int err = 0; 322 317 318 + lock_kernel(); 323 319 err = fasync_helper(fd, file, on, &data->fasync); 324 320 if (err < 0) 325 - return err; 321 + goto out; 326 322 327 323 if (on) 328 324 data->flags |= VHCI_FASYNC; 329 325 else 330 326 data->flags &= ~VHCI_FASYNC; 331 327 332 - return 0; 328 + out: 329 + unlock_kernel(); 330 + return err; 333 331 } 334 332 335 333 static const struct file_operations vhci_fops = {
+4
drivers/char/agp/frontend.c
··· 39 39 #include <linux/mm.h> 40 40 #include <linux/fs.h> 41 41 #include <linux/sched.h> 42 + #include <linux/smp_lock.h> 42 43 #include <asm/uaccess.h> 43 44 #include <asm/pgtable.h> 44 45 #include "agp.h" ··· 678 677 struct agp_client *client; 679 678 int rc = -ENXIO; 680 679 680 + lock_kernel(); 681 681 mutex_lock(&(agp_fe.agp_mutex)); 682 682 683 683 if (minor != AGPGART_MINOR) ··· 705 703 agp_insert_file_private(priv); 706 704 DBG("private=%p, client=%p", priv, client); 707 705 mutex_unlock(&(agp_fe.agp_mutex)); 706 + unlock_kernel(); 708 707 return 0; 709 708 710 709 err_out_nomem: 711 710 rc = -ENOMEM; 712 711 err_out: 713 712 mutex_unlock(&(agp_fe.agp_mutex)); 713 + unlock_kernel(); 714 714 return rc; 715 715 } 716 716
+3
drivers/char/apm-emulation.c
··· 13 13 #include <linux/module.h> 14 14 #include <linux/poll.h> 15 15 #include <linux/slab.h> 16 + #include <linux/smp_lock.h> 16 17 #include <linux/proc_fs.h> 17 18 #include <linux/seq_file.h> 18 19 #include <linux/miscdevice.h> ··· 417 416 { 418 417 struct apm_user *as; 419 418 419 + lock_kernel(); 420 420 as = kzalloc(sizeof(*as), GFP_KERNEL); 421 421 if (as) { 422 422 /* ··· 437 435 438 436 filp->private_data = as; 439 437 } 438 + unlock_kernel(); 440 439 441 440 return as ? 0 : -ENOMEM; 442 441 }
+7 -2
drivers/char/briq_panel.c
··· 6 6 7 7 #include <linux/module.h> 8 8 9 + #include <linux/smp_lock.h> 9 10 #include <linux/types.h> 10 11 #include <linux/errno.h> 11 12 #include <linux/tty.h> ··· 68 67 69 68 static int briq_panel_open(struct inode *ino, struct file *filep) 70 69 { 71 - /* enforce single access */ 72 - if (vfd_is_open) 70 + lock_kernel(); 71 + /* enforce single access, vfd_is_open is protected by BKL */ 72 + if (vfd_is_open) { 73 + unlock_kernel(); 73 74 return -EBUSY; 75 + } 74 76 vfd_is_open = 1; 75 77 78 + unlock_kernel(); 76 79 return 0; 77 80 } 78 81
+2
drivers/char/cs5535_gpio.c
··· 17 17 #include <linux/cdev.h> 18 18 #include <linux/ioport.h> 19 19 #include <linux/pci.h> 20 + #include <linux/smp_lock.h> 20 21 #include <asm/uaccess.h> 21 22 #include <asm/io.h> 22 23 ··· 158 157 { 159 158 u32 m = iminor(inode); 160 159 160 + cycle_kernel_lock(); 161 161 /* the mask says which pins are usable by this driver */ 162 162 if ((mask & (1 << m)) == 0) 163 163 return -EINVAL;
+4
drivers/char/ds1286.c
··· 27 27 * option) any later version. 28 28 */ 29 29 #include <linux/ds1286.h> 30 + #include <linux/smp_lock.h> 30 31 #include <linux/types.h> 31 32 #include <linux/errno.h> 32 33 #include <linux/miscdevice.h> ··· 253 252 254 253 static int ds1286_open(struct inode *inode, struct file *file) 255 254 { 255 + lock_kernel(); 256 256 spin_lock_irq(&ds1286_lock); 257 257 258 258 if (ds1286_status & RTC_IS_OPEN) ··· 262 260 ds1286_status |= RTC_IS_OPEN; 263 261 264 262 spin_unlock_irq(&ds1286_lock); 263 + unlock_kernel(); 265 264 return 0; 266 265 267 266 out_busy: 268 267 spin_lock_irq(&ds1286_lock); 268 + unlock_kernel(); 269 269 return -EBUSY; 270 270 } 271 271
+8 -1
drivers/char/ds1620.c
··· 8 8 #include <linux/proc_fs.h> 9 9 #include <linux/capability.h> 10 10 #include <linux/init.h> 11 + #include <linux/smp_lock.h> 11 12 12 13 #include <asm/hardware.h> 13 14 #include <asm/mach-types.h> ··· 209 208 therm->hi = cvt_9_to_int(ds1620_in(THERM_READ_TH, 9)); 210 209 } 211 210 211 + static int ds1620_open(struct inode *inode, struct file *file) 212 + { 213 + cycle_kernel_lock(); 214 + return nonseekable_open(inode, file); 215 + } 216 + 212 217 static ssize_t 213 218 ds1620_read(struct file *file, char __user *buf, size_t count, loff_t *ptr) 214 219 { ··· 343 336 344 337 static const struct file_operations ds1620_fops = { 345 338 .owner = THIS_MODULE, 346 - .open = nonseekable_open, 339 + .open = ds1620_open, 347 340 .read = ds1620_read, 348 341 .ioctl = ds1620_ioctl, 349 342 };
+11 -5
drivers/char/dsp56k.c
··· 33 33 #include <linux/mm.h> 34 34 #include <linux/init.h> 35 35 #include <linux/device.h> 36 + #include <linux/smp_lock.h> 36 37 37 38 #include <asm/atarihw.h> 38 39 #include <asm/traps.h> ··· 437 436 static int dsp56k_open(struct inode *inode, struct file *file) 438 437 { 439 438 int dev = iminor(inode) & 0x0f; 439 + int ret = 0; 440 440 441 + lock_kernel(); 441 442 switch(dev) 442 443 { 443 444 case DSP56K_DEV_56001: 444 445 445 - if (test_and_set_bit(0, &dsp56k.in_use)) 446 - return -EBUSY; 446 + if (test_and_set_bit(0, &dsp56k.in_use)) { 447 + ret = -EBUSY; 448 + goto out; 449 + } 447 450 448 451 dsp56k.timeout = TIMEOUT; 449 452 dsp56k.maxio = MAXIO; ··· 463 458 break; 464 459 465 460 default: 466 - return -ENODEV; 461 + ret = -ENODEV; 467 462 } 468 - 469 - return 0; 463 + out: 464 + unlock_kernel(); 465 + return ret; 470 466 } 471 467 472 468 static int dsp56k_release(struct inode *inode, struct file *file)
+3
drivers/char/dtlk.c
··· 56 56 #include <linux/errno.h> /* for -EBUSY */ 57 57 #include <linux/ioport.h> /* for request_region */ 58 58 #include <linux/delay.h> /* for loops_per_jiffy */ 59 + #include <linux/smp_lock.h> /* cycle_kernel_lock() */ 59 60 #include <asm/io.h> /* for inb_p, outb_p, inb, outb, etc. */ 60 61 #include <asm/uaccess.h> /* for get_user, etc. */ 61 62 #include <linux/wait.h> /* for wait_queue */ ··· 289 288 } 290 289 } 291 290 291 + /* Note that nobody ever sets dtlk_busy... */ 292 292 static int dtlk_open(struct inode *inode, struct file *file) 293 293 { 294 294 TRACE_TEXT("(dtlk_open"); 295 295 296 + cycle_kernel_lock(); 296 297 nonseekable_open(inode, file); 297 298 switch (iminor(inode)) { 298 299 case DTLK_MINOR:
+2
drivers/char/efirtc.c
··· 28 28 */ 29 29 30 30 31 + #include <linux/smp_lock.h> 31 32 #include <linux/types.h> 32 33 #include <linux/errno.h> 33 34 #include <linux/miscdevice.h> ··· 273 272 * We do accept multiple open files at the same time as we 274 273 * synchronize on the per call operation. 275 274 */ 275 + cycle_kernel_lock(); 276 276 return 0; 277 277 } 278 278
+6 -1
drivers/char/genrtc.c
··· 51 51 #include <linux/init.h> 52 52 #include <linux/poll.h> 53 53 #include <linux/proc_fs.h> 54 + #include <linux/smp_lock.h> 54 55 #include <linux/workqueue.h> 55 56 56 57 #include <asm/uaccess.h> ··· 339 338 340 339 static int gen_rtc_open(struct inode *inode, struct file *file) 341 340 { 342 - if (gen_rtc_status & RTC_IS_OPEN) 341 + lock_kernel(); 342 + if (gen_rtc_status & RTC_IS_OPEN) { 343 + unlock_kernel(); 343 344 return -EBUSY; 345 + } 344 346 345 347 gen_rtc_status |= RTC_IS_OPEN; 346 348 gen_rtc_irq_data = 0; 347 349 irq_active = 0; 350 + unlock_kernel(); 348 351 349 352 return 0; 350 353 }
+4
drivers/char/hpet.c
··· 14 14 #include <linux/interrupt.h> 15 15 #include <linux/module.h> 16 16 #include <linux/kernel.h> 17 + #include <linux/smp_lock.h> 17 18 #include <linux/types.h> 18 19 #include <linux/miscdevice.h> 19 20 #include <linux/major.h> ··· 194 193 if (file->f_mode & FMODE_WRITE) 195 194 return -EINVAL; 196 195 196 + lock_kernel(); 197 197 spin_lock_irq(&hpet_lock); 198 198 199 199 for (devp = NULL, hpetp = hpets; hpetp && !devp; hpetp = hpetp->hp_next) ··· 209 207 210 208 if (!devp) { 211 209 spin_unlock_irq(&hpet_lock); 210 + unlock_kernel(); 212 211 return -EBUSY; 213 212 } 214 213 ··· 217 214 devp->hd_irqdata = 0; 218 215 devp->hd_flags |= HPET_OPEN; 219 216 spin_unlock_irq(&hpet_lock); 217 + unlock_kernel(); 220 218 221 219 return 0; 222 220 }
+2
drivers/char/hw_random/core.c
··· 37 37 #include <linux/kernel.h> 38 38 #include <linux/fs.h> 39 39 #include <linux/sched.h> 40 + #include <linux/smp_lock.h> 40 41 #include <linux/init.h> 41 42 #include <linux/miscdevice.h> 42 43 #include <linux/delay.h> ··· 87 86 return -EINVAL; 88 87 if (filp->f_mode & FMODE_WRITE) 89 88 return -EINVAL; 89 + cycle_kernel_lock(); 90 90 return 0; 91 91 } 92 92
+2 -32
drivers/char/ip2/ip2main.c
··· 98 98 #include <linux/major.h> 99 99 #include <linux/wait.h> 100 100 #include <linux/device.h> 101 + #include <linux/smp_lock.h> 101 102 102 103 #include <linux/tty.h> 103 104 #include <linux/tty_flip.h> ··· 2909 2908 static int 2910 2909 ip2_ipl_open( struct inode *pInode, struct file *pFile ) 2911 2910 { 2912 - unsigned int iplminor = iminor(pInode); 2913 - i2eBordStrPtr pB; 2914 - i2ChanStrPtr pCh; 2915 2911 2916 2912 #ifdef IP2DEBUG_IPL 2917 2913 printk (KERN_DEBUG "IP2IPL: open\n" ); 2918 2914 #endif 2919 - 2920 - switch(iplminor) { 2921 - // These are the IPL devices 2922 - case 0: 2923 - case 4: 2924 - case 8: 2925 - case 12: 2926 - break; 2927 - 2928 - // These are the status devices 2929 - case 1: 2930 - case 5: 2931 - case 9: 2932 - case 13: 2933 - break; 2934 - 2935 - // These are the debug devices 2936 - case 2: 2937 - case 6: 2938 - case 10: 2939 - case 14: 2940 - pB = i2BoardPtrTable[iplminor / 4]; 2941 - pCh = (i2ChanStrPtr) pB->i2eChannelPtr; 2942 - break; 2943 - 2944 - // This is the trace device 2945 - case 3: 2946 - break; 2947 - } 2915 + cycle_kernel_lock(); 2948 2916 return 0; 2949 2917 } 2950 2918
+4
drivers/char/ip27-rtc.c
··· 27 27 #include <linux/bcd.h> 28 28 #include <linux/module.h> 29 29 #include <linux/kernel.h> 30 + #include <linux/smp_lock.h> 30 31 #include <linux/types.h> 31 32 #include <linux/miscdevice.h> 32 33 #include <linux/ioport.h> ··· 164 163 165 164 static int rtc_open(struct inode *inode, struct file *file) 166 165 { 166 + lock_kernel(); 167 167 spin_lock_irq(&rtc_lock); 168 168 169 169 if (rtc_status & RTC_IS_OPEN) { 170 170 spin_unlock_irq(&rtc_lock); 171 + unlock_kernel(); 171 172 return -EBUSY; 172 173 } 173 174 174 175 rtc_status |= RTC_IS_OPEN; 175 176 spin_unlock_irq(&rtc_lock); 177 + unlock_kernel(); 176 178 177 179 return 0; 178 180 }
+8 -2
drivers/char/ipmi/ipmi_devintf.c
··· 43 43 #include <linux/init.h> 44 44 #include <linux/device.h> 45 45 #include <linux/compat.h> 46 + #include <linux/smp_lock.h> 46 47 47 48 struct ipmi_file_private 48 49 { ··· 101 100 struct ipmi_file_private *priv = file->private_data; 102 101 int result; 103 102 103 + lock_kernel(); /* could race against open() otherwise */ 104 104 result = fasync_helper(fd, file, on, &priv->fasync_queue); 105 + unlock_kernel(); 105 106 106 107 return (result); 107 108 } ··· 124 121 if (!priv) 125 122 return -ENOMEM; 126 123 124 + lock_kernel(); 127 125 priv->file = file; 128 126 129 127 rv = ipmi_create_user(if_num, ··· 133 129 &(priv->user)); 134 130 if (rv) { 135 131 kfree(priv); 136 - return rv; 132 + goto out; 137 133 } 138 134 139 135 file->private_data = priv; ··· 148 144 priv->default_retries = -1; 149 145 priv->default_retry_time_ms = 0; 150 146 151 - return 0; 147 + out: 148 + unlock_kernel(); 149 + return rv; 152 150 } 153 151 154 152 static int ipmi_release(struct inode *inode, struct file *file)
+3
drivers/char/ipmi/ipmi_watchdog.c
··· 35 35 #include <linux/moduleparam.h> 36 36 #include <linux/ipmi.h> 37 37 #include <linux/ipmi_smi.h> 38 + #include <linux/smp_lock.h> 38 39 #include <linux/watchdog.h> 39 40 #include <linux/miscdevice.h> 40 41 #include <linux/init.h> ··· 818 817 case WATCHDOG_MINOR: 819 818 if (test_and_set_bit(0, &ipmi_wdog_open)) 820 819 return -EBUSY; 820 + 821 + cycle_kernel_lock(); 821 822 822 823 /* 823 824 * Don't start the timer now, let it start on the
+3
drivers/char/lcd.c
··· 20 20 #include <linux/mc146818rtc.h> 21 21 #include <linux/netdevice.h> 22 22 #include <linux/sched.h> 23 + #include <linux/smp_lock.h> 23 24 #include <linux/delay.h> 24 25 25 26 #include <asm/io.h> ··· 415 414 416 415 static int lcd_open(struct inode *inode, struct file *file) 417 416 { 417 + cycle_kernel_lock(); 418 + 418 419 if (!lcd_present) 419 420 return -ENXIO; 420 421 else
+26 -12
drivers/char/lp.c
··· 126 126 #include <linux/device.h> 127 127 #include <linux/wait.h> 128 128 #include <linux/jiffies.h> 129 + #include <linux/smp_lock.h> 129 130 130 131 #include <linux/parport.h> 131 132 #undef LP_STATS ··· 490 489 static int lp_open(struct inode * inode, struct file * file) 491 490 { 492 491 unsigned int minor = iminor(inode); 492 + int ret = 0; 493 493 494 - if (minor >= LP_NO) 495 - return -ENXIO; 496 - if ((LP_F(minor) & LP_EXIST) == 0) 497 - return -ENXIO; 498 - if (test_and_set_bit(LP_BUSY_BIT_POS, &LP_F(minor))) 499 - return -EBUSY; 500 - 494 + lock_kernel(); 495 + if (minor >= LP_NO) { 496 + ret = -ENXIO; 497 + goto out; 498 + } 499 + if ((LP_F(minor) & LP_EXIST) == 0) { 500 + ret = -ENXIO; 501 + goto out; 502 + } 503 + if (test_and_set_bit(LP_BUSY_BIT_POS, &LP_F(minor))) { 504 + ret = -EBUSY; 505 + goto out; 506 + } 501 507 /* If ABORTOPEN is set and the printer is offline or out of paper, 502 508 we may still want to open it to perform ioctl()s. Therefore we 503 509 have commandeered O_NONBLOCK, even though it is being used in ··· 518 510 if (status & LP_POUTPA) { 519 511 printk(KERN_INFO "lp%d out of paper\n", minor); 520 512 LP_F(minor) &= ~LP_BUSY; 521 - return -ENOSPC; 513 + ret = -ENOSPC; 514 + goto out; 522 515 } else if (!(status & LP_PSELECD)) { 523 516 printk(KERN_INFO "lp%d off-line\n", minor); 524 517 LP_F(minor) &= ~LP_BUSY; 525 - return -EIO; 518 + ret = -EIO; 519 + goto out; 526 520 } else if (!(status & LP_PERRORP)) { 527 521 printk(KERN_ERR "lp%d printer error\n", minor); 528 522 LP_F(minor) &= ~LP_BUSY; 529 - return -EIO; 523 + ret = -EIO; 524 + goto out; 530 525 } 531 526 } 532 527 lp_table[minor].lp_buffer = kmalloc(LP_BUFFER_SIZE, GFP_KERNEL); 533 528 if (!lp_table[minor].lp_buffer) { 534 529 LP_F(minor) &= ~LP_BUSY; 535 - return -ENOMEM; 530 + ret = -ENOMEM; 531 + goto out; 536 532 } 537 533 /* Determine if the peripheral supports ECP mode */ 538 534 lp_claim_parport_or_block (&lp_table[minor]); ··· 552 540 parport_negotiate (lp_table[minor].dev->port, IEEE1284_MODE_COMPAT); 553 541 lp_release_parport (&lp_table[minor]); 554 542 lp_table[minor].current_mode = IEEE1284_MODE_COMPAT; 555 - return 0; 543 + out: 544 + unlock_kernel(); 545 + return ret; 556 546 } 557 547 558 548 static int lp_release(struct inode * inode, struct file * file)
+5
drivers/char/mbcs.c
··· 24 24 #include <linux/mm.h> 25 25 #include <linux/uio.h> 26 26 #include <linux/mutex.h> 27 + #include <linux/smp_lock.h> 27 28 #include <asm/io.h> 28 29 #include <asm/uaccess.h> 29 30 #include <asm/system.h> ··· 383 382 struct mbcs_soft *soft; 384 383 int minor; 385 384 385 + lock_kernel(); 386 386 minor = iminor(ip); 387 387 388 + /* Nothing protects access to this list... */ 388 389 list_for_each_entry(soft, &soft_list, list) { 389 390 if (soft->nasid == minor) { 390 391 fp->private_data = soft->cxdev; 392 + unlock_kernel(); 391 393 return 0; 392 394 } 393 395 } 394 396 397 + unlock_kernel(); 395 398 return -ENODEV; 396 399 } 397 400
+8 -2
drivers/char/mem.c
··· 26 26 #include <linux/bootmem.h> 27 27 #include <linux/splice.h> 28 28 #include <linux/pfn.h> 29 + #include <linux/smp_lock.h> 29 30 30 31 #include <asm/uaccess.h> 31 32 #include <asm/io.h> ··· 890 889 891 890 static int memory_open(struct inode * inode, struct file * filp) 892 891 { 892 + int ret = 0; 893 + 894 + lock_kernel(); 893 895 switch (iminor(inode)) { 894 896 case 1: 895 897 filp->f_op = &mem_fops; ··· 936 932 break; 937 933 #endif 938 934 default: 935 + unlock_kernel(); 939 936 return -ENXIO; 940 937 } 941 938 if (filp->f_op && filp->f_op->open) 942 - return filp->f_op->open(inode,filp); 943 - return 0; 939 + ret = filp->f_op->open(inode,filp); 940 + unlock_kernel(); 941 + return ret; 944 942 } 945 943 946 944 static const struct file_operations memory_fops = {
+3
drivers/char/misc.c
··· 49 49 #include <linux/device.h> 50 50 #include <linux/tty.h> 51 51 #include <linux/kmod.h> 52 + #include <linux/smp_lock.h> 52 53 53 54 /* 54 55 * Head entry for the doubly linked miscdevice list ··· 119 118 int err = -ENODEV; 120 119 const struct file_operations *old_fops, *new_fops = NULL; 121 120 121 + lock_kernel(); 122 122 mutex_lock(&misc_mtx); 123 123 124 124 list_for_each_entry(c, &misc_list, list) { ··· 157 155 fops_put(old_fops); 158 156 fail: 159 157 mutex_unlock(&misc_mtx); 158 + unlock_kernel(); 160 159 return err; 161 160 } 162 161
+2
drivers/char/mwave/mwavedd.c
··· 56 56 #include <linux/serial.h> 57 57 #include <linux/sched.h> 58 58 #include <linux/spinlock.h> 59 + #include <linux/smp_lock.h> 59 60 #include <linux/delay.h> 60 61 #include <linux/serial_8250.h> 61 62 #include "smapi.h" ··· 101 100 PRINTK_2(TRACE_MWAVE, 102 101 "mwavedd::mwave_open, exit return retval %x\n", retval); 103 102 103 + cycle_kernel_lock(); 104 104 return retval; 105 105 } 106 106
+4
drivers/char/nvram.c
··· 107 107 #include <linux/init.h> 108 108 #include <linux/proc_fs.h> 109 109 #include <linux/spinlock.h> 110 + #include <linux/smp_lock.h> 110 111 111 112 #include <asm/io.h> 112 113 #include <asm/uaccess.h> ··· 334 333 static int 335 334 nvram_open(struct inode *inode, struct file *file) 336 335 { 336 + lock_kernel(); 337 337 spin_lock(&nvram_state_lock); 338 338 339 339 if ((nvram_open_cnt && (file->f_flags & O_EXCL)) || 340 340 (nvram_open_mode & NVRAM_EXCL) || 341 341 ((file->f_mode & 2) && (nvram_open_mode & NVRAM_WRITE))) { 342 342 spin_unlock(&nvram_state_lock); 343 + unlock_kernel(); 343 344 return -EBUSY; 344 345 } 345 346 ··· 352 349 nvram_open_cnt++; 353 350 354 351 spin_unlock(&nvram_state_lock); 352 + unlock_kernel(); 355 353 356 354 return 0; 357 355 }
+2
drivers/char/pc8736x_gpio.c
··· 20 20 #include <linux/mutex.h> 21 21 #include <linux/nsc_gpio.h> 22 22 #include <linux/platform_device.h> 23 + #include <linux/smp_lock.h> 23 24 #include <asm/uaccess.h> 24 25 25 26 #define DEVNAME "pc8736x_gpio" ··· 218 217 unsigned m = iminor(inode); 219 218 file->private_data = &pc8736x_gpio_ops; 220 219 220 + cycle_kernel_lock(); 221 221 dev_dbg(&pdev->dev, "open %d\n", m); 222 222 223 223 if (m >= PC8736X_GPIO_CT)
+2
drivers/char/ppdev.c
··· 66 66 #include <linux/poll.h> 67 67 #include <linux/major.h> 68 68 #include <linux/ppdev.h> 69 + #include <linux/smp_lock.h> 69 70 #include <asm/uaccess.h> 70 71 71 72 #define PP_VERSION "ppdev: user-space parallel port driver" ··· 639 638 unsigned int minor = iminor(inode); 640 639 struct pp_struct *pp; 641 640 641 + cycle_kernel_lock(); 642 642 if (minor >= PARPORT_MAX) 643 643 return -ENXIO; 644 644
+3
drivers/char/raw.c
··· 19 19 #include <linux/cdev.h> 20 20 #include <linux/device.h> 21 21 #include <linux/mutex.h> 22 + #include <linux/smp_lock.h> 22 23 23 24 #include <asm/uaccess.h> 24 25 ··· 54 53 return 0; 55 54 } 56 55 56 + lock_kernel(); 57 57 mutex_lock(&raw_mutex); 58 58 59 59 /* ··· 81 79 bdev->bd_inode->i_mapping; 82 80 filp->private_data = bdev; 83 81 mutex_unlock(&raw_mutex); 82 + unlock_kernel(); 84 83 return 0; 85 84 86 85 out2:
+4
drivers/char/rtc.c
··· 73 73 #include <linux/proc_fs.h> 74 74 #include <linux/seq_file.h> 75 75 #include <linux/spinlock.h> 76 + #include <linux/smp_lock.h> 76 77 #include <linux/sysctl.h> 77 78 #include <linux/wait.h> 78 79 #include <linux/bcd.h> ··· 735 734 * needed here. Or anywhere else in this driver. */ 736 735 static int rtc_open(struct inode *inode, struct file *file) 737 736 { 737 + lock_kernel(); 738 738 spin_lock_irq(&rtc_lock); 739 739 740 740 if (rtc_status & RTC_IS_OPEN) ··· 745 743 746 744 rtc_irq_data = 0; 747 745 spin_unlock_irq(&rtc_lock); 746 + unlock_kernel(); 748 747 return 0; 749 748 750 749 out_busy: 751 750 spin_unlock_irq(&rtc_lock); 751 + unlock_kernel(); 752 752 return -EBUSY; 753 753 } 754 754
+2
drivers/char/scx200_gpio.c
··· 12 12 #include <linux/kernel.h> 13 13 #include <linux/init.h> 14 14 #include <linux/platform_device.h> 15 + #include <linux/smp_lock.h> 15 16 #include <asm/uaccess.h> 16 17 #include <asm/io.h> 17 18 ··· 52 51 unsigned m = iminor(inode); 53 52 file->private_data = &scx200_gpio_ops; 54 53 54 + cycle_kernel_lock(); 55 55 if (m >= MAX_PINS) 56 56 return -EINVAL; 57 57 return nonseekable_open(inode, file);
+4 -1
drivers/char/snsc.c
··· 21 21 #include <linux/poll.h> 22 22 #include <linux/module.h> 23 23 #include <linux/slab.h> 24 + #include <linux/smp_lock.h> 24 25 #include <asm/sn/io.h> 25 26 #include <asm/sn/sn_sal.h> 26 27 #include <asm/sn/module.h> ··· 105 104 file->private_data = sd; 106 105 107 106 /* hook this subchannel up to the system controller interrupt */ 107 + lock_kernel(); 108 108 rv = request_irq(SGI_UART_VECTOR, scdrv_interrupt, 109 109 IRQF_SHARED | IRQF_DISABLED, 110 110 SYSCTL_BASENAME, sd); ··· 113 111 ia64_sn_irtr_close(sd->sd_nasid, sd->sd_subch); 114 112 kfree(sd); 115 113 printk("%s: irq request failed (%d)\n", __func__, rv); 114 + unlock_kernel(); 116 115 return -EBUSY; 117 116 } 118 - 117 + unlock_kernel(); 119 118 return 0; 120 119 } 121 120
+3
drivers/char/sonypi.c
··· 49 49 #include <linux/err.h> 50 50 #include <linux/kfifo.h> 51 51 #include <linux/platform_device.h> 52 + #include <linux/smp_lock.h> 52 53 53 54 #include <asm/uaccess.h> 54 55 #include <asm/io.h> ··· 907 906 908 907 static int sonypi_misc_open(struct inode *inode, struct file *file) 909 908 { 909 + lock_kernel(); 910 910 mutex_lock(&sonypi_device.lock); 911 911 /* Flush input queue on first open */ 912 912 if (!sonypi_device.open_count) 913 913 kfifo_reset(sonypi_device.fifo); 914 914 sonypi_device.open_count++; 915 915 mutex_unlock(&sonypi_device.lock); 916 + unlock_kernel(); 916 917 return 0; 917 918 } 918 919
+2
drivers/char/tb0219.c
··· 21 21 #include <linux/fs.h> 22 22 #include <linux/init.h> 23 23 #include <linux/module.h> 24 + #include <linux/smp_lock.h> 24 25 25 26 #include <asm/io.h> 26 27 #include <asm/reboot.h> ··· 237 236 { 238 237 unsigned int minor; 239 238 239 + cycle_kernel_lock(); 240 240 minor = iminor(inode); 241 241 switch (minor) { 242 242 case 0:
+12 -7
drivers/char/tlclk.c
··· 36 36 #include <linux/ioport.h> 37 37 #include <linux/interrupt.h> 38 38 #include <linux/spinlock.h> 39 + #include <linux/smp_lock.h> 39 40 #include <linux/timer.h> 40 41 #include <linux/sysfs.h> 41 42 #include <linux/device.h> ··· 205 204 { 206 205 int result; 207 206 208 - if (test_and_set_bit(0, &useflags)) 209 - return -EBUSY; 207 + lock_kernel(); 208 + if (test_and_set_bit(0, &useflags)) { 209 + result = -EBUSY; 210 210 /* this legacy device is always one per system and it doesn't 211 211 * know how to handle multiple concurrent clients. 212 212 */ 213 + goto out; 214 + } 213 215 214 216 /* Make sure there is no interrupt pending while 215 217 * initialising interrupt handler */ ··· 222 218 * we can't share this IRQ */ 223 219 result = request_irq(telclk_interrupt, &tlclk_interrupt, 224 220 IRQF_DISABLED, "telco_clock", tlclk_interrupt); 225 - if (result == -EBUSY) { 221 + if (result == -EBUSY) 226 222 printk(KERN_ERR "tlclk: Interrupt can't be reserved.\n"); 227 - return -EBUSY; 228 - } 229 - inb(TLCLK_REG6); /* Clear interrupt events */ 223 + else 224 + inb(TLCLK_REG6); /* Clear interrupt events */ 230 225 231 - return 0; 226 + out: 227 + unlock_kernel(); 228 + return result; 232 229 } 233 230 234 231 static int tlclk_release(struct inode *inode, struct file *filp)
+5
drivers/char/tpm/tpm.c
··· 26 26 #include <linux/poll.h> 27 27 #include <linux/mutex.h> 28 28 #include <linux/spinlock.h> 29 + #include <linux/smp_lock.h> 29 30 30 31 #include "tpm.h" 31 32 ··· 898 897 int rc = 0, minor = iminor(inode); 899 898 struct tpm_chip *chip = NULL, *pos; 900 899 900 + lock_kernel(); 901 901 spin_lock(&driver_lock); 902 902 903 903 list_for_each_entry(pos, &tpm_chip_list, list) { ··· 928 926 if (chip->data_buffer == NULL) { 929 927 chip->num_opens--; 930 928 put_device(chip->dev); 929 + unlock_kernel(); 931 930 return -ENOMEM; 932 931 } 933 932 934 933 atomic_set(&chip->data_pending, 0); 935 934 936 935 file->private_data = chip; 936 + unlock_kernel(); 937 937 return 0; 938 938 939 939 err_out: 940 940 spin_unlock(&driver_lock); 941 + unlock_kernel(); 941 942 return rc; 942 943 } 943 944 EXPORT_SYMBOL_GPL(tpm_open);
+34 -7
drivers/char/tty_io.c
··· 2665 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 2670 struct tty_struct *tty; 2671 2671 int noctty, retval; ··· 2779 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 2795 #ifdef CONFIG_UNIX98_PTYS 2783 2796 /** 2784 2797 * ptmx_open - open a unix 98 pty master ··· 2805 2792 * allocated_ptys_lock handles the list of free pty numbers 2806 2793 */ 2807 2794 2808 - static int ptmx_open(struct inode *inode, struct file *filp) 2795 + static int __ptmx_open(struct inode *inode, struct file *filp) 2809 2796 { 2810 2797 struct tty_struct *tty; 2811 2798 int retval; ··· 2843 2830 out: 2844 2831 devpts_kill_index(index); 2845 2832 return retval; 2833 + } 2834 + 2835 + static int ptmx_open(struct inode *inode, struct file *filp) 2836 + { 2837 + int ret; 2838 + 2839 + lock_kernel(); 2840 + ret = __ptmx_open(inode, filp); 2841 + unlock_kernel(); 2842 + return ret; 2846 2843 } 2847 2844 #endif 2848 2845 ··· 2909 2886 { 2910 2887 struct tty_struct *tty; 2911 2888 unsigned long flags; 2912 - int retval; 2889 + int retval = 0; 2913 2890 2891 + lock_kernel(); 2914 2892 tty = (struct tty_struct *)filp->private_data; 2915 2893 if (tty_paranoia_check(tty, filp->f_path.dentry->d_inode, "tty_fasync")) 2916 - return 0; 2894 + goto out; 2917 2895 2918 2896 retval = fasync_helper(fd, filp, on, &tty->fasync); 2919 2897 if (retval <= 0) 2920 - return retval; 2898 + goto out; 2921 2899 2922 2900 if (on) { 2923 2901 enum pid_type type; ··· 2936 2912 spin_unlock_irqrestore(&tty->ctrl_lock, flags); 2937 2913 retval = __f_setown(filp, pid, type, 0); 2938 2914 if (retval) 2939 - return retval; 2915 + goto out; 2940 2916 } else { 2941 2917 if (!tty->fasync && !waitqueue_active(&tty->read_wait)) 2942 2918 tty->minimum_to_wake = N_TTY_BUF_SIZE; 2943 2919 } 2944 - return 0; 2920 + retval = 0; 2921 + out: 2922 + unlock_kernel(); 2923 + return retval; 2945 2924 } 2946 2925 2947 2926 /**
+7 -2
drivers/char/vc_screen.c
··· 34 34 #include <linux/kbd_kern.h> 35 35 #include <linux/console.h> 36 36 #include <linux/device.h> 37 + #include <linux/smp_lock.h> 37 38 38 39 #include <asm/uaccess.h> 39 40 #include <asm/byteorder.h> ··· 461 460 vcs_open(struct inode *inode, struct file *filp) 462 461 { 463 462 unsigned int currcons = iminor(inode) & 127; 463 + int ret = 0; 464 + 465 + lock_kernel(); 464 466 if(currcons && !vc_cons_allocated(currcons-1)) 465 - return -ENXIO; 466 - return 0; 467 + ret = -ENXIO; 468 + unlock_kernel(); 469 + return ret; 467 470 } 468 471 469 472 static const struct file_operations vcs_fops = {
+3
drivers/char/viotape.c
··· 46 46 #include <linux/completion.h> 47 47 #include <linux/proc_fs.h> 48 48 #include <linux/seq_file.h> 49 + #include <linux/smp_lock.h> 49 50 50 51 #include <asm/uaccess.h> 51 52 #include <asm/ioctls.h> ··· 688 687 if (op == NULL) 689 688 return -ENOMEM; 690 689 690 + lock_kernel(); 691 691 get_dev_info(file->f_path.dentry->d_inode, &devi); 692 692 693 693 /* Note: We currently only support one mode! */ ··· 719 717 720 718 free_op: 721 719 free_op_struct(op); 720 + unlock_kernel(); 722 721 return ret; 723 722 } 724 723
+2
drivers/char/vr41xx_giu.c
··· 27 27 #include <linux/kernel.h> 28 28 #include <linux/module.h> 29 29 #include <linux/platform_device.h> 30 + #include <linux/smp_lock.h> 30 31 #include <linux/spinlock.h> 31 32 #include <linux/types.h> 32 33 ··· 548 547 { 549 548 unsigned int pin; 550 549 550 + cycle_kernel_lock(); 551 551 pin = iminor(inode); 552 552 if (pin >= giu_nr_pins) 553 553 return -EBADF;
+5 -1
drivers/char/xilinx_hwicap/xilinx_hwicap.c
··· 85 85 #include <linux/poll.h> 86 86 #include <linux/proc_fs.h> 87 87 #include <linux/mutex.h> 88 + #include <linux/smp_lock.h> 88 89 #include <linux/sysctl.h> 89 90 #include <linux/version.h> 90 91 #include <linux/fs.h> ··· 505 504 struct hwicap_drvdata *drvdata; 506 505 int status; 507 506 507 + lock_kernel(); 508 508 drvdata = container_of(inode->i_cdev, struct hwicap_drvdata, cdev); 509 509 510 510 status = mutex_lock_interruptible(&drvdata->sem); 511 511 if (status) 512 - return status; 512 + goto out; 513 513 514 514 if (drvdata->is_open) { 515 515 status = -EBUSY; ··· 530 528 531 529 error: 532 530 mutex_unlock(&drvdata->sem); 531 + out: 532 + unlock_kernel(); 533 533 return status; 534 534 } 535 535
+7 -2
drivers/gpu/drm/drm_fops.c
··· 37 37 #include "drmP.h" 38 38 #include "drm_sarea.h" 39 39 #include <linux/poll.h> 40 + #include <linux/smp_lock.h> 40 41 41 42 static int drm_open_helper(struct inode *inode, struct file *filp, 42 43 struct drm_device * dev); ··· 175 174 176 175 DRM_DEBUG("\n"); 177 176 177 + /* BKL pushdown: note that nothing else serializes idr_find() */ 178 + lock_kernel(); 178 179 minor = idr_find(&drm_minors_idr, minor_id); 179 180 if (!minor) 180 - return -ENODEV; 181 + goto out; 181 182 182 183 if (!(dev = minor->dev)) 183 - return -ENODEV; 184 + goto out; 184 185 185 186 old_fops = filp->f_op; 186 187 filp->f_op = fops_get(&dev->driver->fops); ··· 192 189 } 193 190 fops_put(old_fops); 194 191 192 + out: 193 + unlock_kernel(); 195 194 return err; 196 195 } 197 196
+3
drivers/hid/hidraw.c
··· 30 30 #include <linux/major.h> 31 31 #include <linux/hid.h> 32 32 #include <linux/mutex.h> 33 + #include <linux/smp_lock.h> 33 34 34 35 #include <linux/hidraw.h> 35 36 ··· 158 157 struct hidraw_list *list; 159 158 int err = 0; 160 159 160 + lock_kernel(); 161 161 if (!(list = kzalloc(sizeof(struct hidraw_list), GFP_KERNEL))) { 162 162 err = -ENOMEM; 163 163 goto out; ··· 185 183 out_unlock: 186 184 spin_unlock(&minors_lock); 187 185 out: 186 + unlock_kernel(); 188 187 return err; 189 188 190 189 }
+16 -6
drivers/i2c/i2c-dev.c
··· 34 34 #include <linux/list.h> 35 35 #include <linux/i2c.h> 36 36 #include <linux/i2c-dev.h> 37 + #include <linux/smp_lock.h> 37 38 #include <asm/uaccess.h> 38 39 39 40 static struct i2c_driver i2cdev_driver; ··· 442 441 struct i2c_client *client; 443 442 struct i2c_adapter *adap; 444 443 struct i2c_dev *i2c_dev; 444 + int ret = 0; 445 445 446 + lock_kernel(); 446 447 i2c_dev = i2c_dev_get_by_minor(minor); 447 - if (!i2c_dev) 448 - return -ENODEV; 448 + if (!i2c_dev) { 449 + ret = -ENODEV; 450 + goto out; 451 + } 449 452 450 453 adap = i2c_get_adapter(i2c_dev->adap->nr); 451 - if (!adap) 452 - return -ENODEV; 454 + if (!adap) { 455 + ret = -ENODEV; 456 + goto out; 457 + } 453 458 454 459 /* This creates an anonymous i2c_client, which may later be 455 460 * pointed to some address using I2C_SLAVE or I2C_SLAVE_FORCE. ··· 467 460 client = kzalloc(sizeof(*client), GFP_KERNEL); 468 461 if (!client) { 469 462 i2c_put_adapter(adap); 470 - return -ENOMEM; 463 + ret = -ENOMEM; 464 + goto out; 471 465 } 472 466 snprintf(client->name, I2C_NAME_SIZE, "i2c-dev %d", adap->nr); 473 467 client->driver = &i2cdev_driver; ··· 476 468 client->adapter = adap; 477 469 file->private_data = client; 478 470 479 - return 0; 471 + out: 472 + unlock_kernel(); 473 + return ret; 480 474 } 481 475 482 476 static int i2cdev_release(struct inode *inode, struct file *file)
+6 -1
drivers/ide/ide-tape.c
··· 2421 2421 if (i >= MAX_HWIFS * MAX_DRIVES) 2422 2422 return -ENXIO; 2423 2423 2424 + lock_kernel(); 2424 2425 tape = ide_tape_chrdev_get(i); 2425 - if (!tape) 2426 + if (!tape) { 2427 + unlock_kernel(); 2426 2428 return -ENXIO; 2429 + } 2427 2430 2428 2431 debug_log(DBG_CHRDEV, "Enter %s\n", __func__); 2429 2432 ··· 2485 2482 } 2486 2483 } 2487 2484 } 2485 + unlock_kernel(); 2488 2486 return 0; 2489 2487 2490 2488 out_put_tape: 2491 2489 ide_tape_put(tape); 2490 + unlock_kernel(); 2492 2491 return retval; 2493 2492 } 2494 2493
+2
drivers/infiniband/core/ucm.c
··· 45 45 #include <linux/cdev.h> 46 46 #include <linux/idr.h> 47 47 #include <linux/mutex.h> 48 + #include <linux/smp_lock.h> 48 49 49 50 #include <asm/uaccess.h> 50 51 ··· 1160 1159 { 1161 1160 struct ib_ucm_file *file; 1162 1161 1162 + cycle_kernel_lock(); 1163 1163 file = kmalloc(sizeof(*file), GFP_KERNEL); 1164 1164 if (!file) 1165 1165 return -ENOMEM;
+3
drivers/infiniband/core/ucma.c
··· 38 38 #include <linux/in.h> 39 39 #include <linux/in6.h> 40 40 #include <linux/miscdevice.h> 41 + #include <linux/smp_lock.h> 41 42 42 43 #include <rdma/rdma_user_cm.h> 43 44 #include <rdma/ib_marshall.h> ··· 1157 1156 if (!file) 1158 1157 return -ENOMEM; 1159 1158 1159 + lock_kernel(); 1160 1160 INIT_LIST_HEAD(&file->event_list); 1161 1161 INIT_LIST_HEAD(&file->ctx_list); 1162 1162 init_waitqueue_head(&file->poll_wait); ··· 1165 1163 1166 1164 filp->private_data = file; 1167 1165 file->filp = filp; 1166 + unlock_kernel(); 1168 1167 return 0; 1169 1168 } 1170 1169
+13
drivers/infiniband/core/user_mad.c
··· 777 777 } 778 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 793 static int ib_umad_open(struct inode *inode, struct file *filp) 781 794 { 782 795 struct ib_umad_port *port;
+12 -1
drivers/infiniband/core/uverbs_main.c
··· 610 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 625 static int ib_uverbs_open(struct inode *inode, struct file *filp) 614 626 { 615 627 struct ib_uverbs_device *dev; ··· 663 651 664 652 err: 665 653 kref_put(&dev->ref, ib_uverbs_release_dev); 666 - 667 654 return ret; 668 655 } 669 656
+2
drivers/infiniband/hw/ipath/ipath_file_ops.c
··· 39 39 #include <linux/highmem.h> 40 40 #include <linux/io.h> 41 41 #include <linux/jiffies.h> 42 + #include <linux/smp_lock.h> 42 43 #include <asm/pgtable.h> 43 44 44 45 #include "ipath_kernel.h" ··· 1816 1815 static int ipath_open(struct inode *in, struct file *fp) 1817 1816 { 1818 1817 /* The real work is performed later in ipath_assign_port() */ 1818 + cycle_kernel_lock(); 1819 1819 fp->private_data = kzalloc(sizeof(struct ipath_filedata), GFP_KERNEL); 1820 1820 return fp->private_data ? 0 : -ENOMEM; 1821 1821 }
+12 -4
drivers/input/input.c
··· 21 21 #include <linux/device.h> 22 22 #include <linux/mutex.h> 23 23 #include <linux/rcupdate.h> 24 + #include <linux/smp_lock.h> 24 25 25 26 MODULE_AUTHOR("Vojtech Pavlik <vojtech@suse.cz>"); 26 27 MODULE_DESCRIPTION("Input core"); ··· 1589 1588 1590 1589 static int input_open_file(struct inode *inode, struct file *file) 1591 1590 { 1592 - struct input_handler *handler = input_table[iminor(inode) >> 5]; 1591 + struct input_handler *handler; 1593 1592 const struct file_operations *old_fops, *new_fops = NULL; 1594 1593 int err; 1595 1594 1595 + lock_kernel(); 1596 1596 /* No load-on-demand here? */ 1597 - if (!handler || !(new_fops = fops_get(handler->fops))) 1598 - return -ENODEV; 1597 + handler = input_table[iminor(inode) >> 5]; 1598 + if (!handler || !(new_fops = fops_get(handler->fops))) { 1599 + err = -ENODEV; 1600 + goto out; 1601 + } 1599 1602 1600 1603 /* 1601 1604 * That's _really_ odd. Usually NULL ->open means "nothing special", ··· 1607 1602 */ 1608 1603 if (!new_fops->open) { 1609 1604 fops_put(new_fops); 1610 - return -ENODEV; 1605 + err = -ENODEV; 1606 + goto out; 1611 1607 } 1612 1608 old_fops = file->f_op; 1613 1609 file->f_op = new_fops; ··· 1620 1614 file->f_op = fops_get(old_fops); 1621 1615 } 1622 1616 fops_put(old_fops); 1617 + out: 1618 + unlock_kernel(); 1623 1619 return err; 1624 1620 } 1625 1621
+2
drivers/input/misc/hp_sdc_rtc.c
··· 35 35 36 36 #include <linux/hp_sdc.h> 37 37 #include <linux/errno.h> 38 + #include <linux/smp_lock.h> 38 39 #include <linux/types.h> 39 40 #include <linux/init.h> 40 41 #include <linux/module.h> ··· 409 408 410 409 static int hp_sdc_rtc_open(struct inode *inode, struct file *file) 411 410 { 411 + cycle_kernel_lock(); 412 412 return 0; 413 413 } 414 414
+3
drivers/input/misc/uinput.c
··· 37 37 #include <linux/fs.h> 38 38 #include <linux/miscdevice.h> 39 39 #include <linux/uinput.h> 40 + #include <linux/smp_lock.h> 40 41 41 42 static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 42 43 { ··· 223 222 if (!newdev) 224 223 return -ENOMEM; 225 224 225 + lock_kernel(); 226 226 mutex_init(&newdev->mutex); 227 227 spin_lock_init(&newdev->requests_lock); 228 228 init_waitqueue_head(&newdev->requests_waitq); ··· 231 229 newdev->state = UIST_NEW_DEVICE; 232 230 233 231 file->private_data = newdev; 232 + unlock_kernel(); 234 233 235 234 return 0; 236 235 }
+10 -2
drivers/input/mousedev.c
··· 14 14 #define MOUSEDEV_MIX 31 15 15 16 16 #include <linux/slab.h> 17 + #include <linux/smp_lock.h> 17 18 #include <linux/poll.h> 18 19 #include <linux/module.h> 19 20 #include <linux/init.h> ··· 546 545 if (i >= MOUSEDEV_MINORS) 547 546 return -ENODEV; 548 547 548 + lock_kernel(); 549 549 error = mutex_lock_interruptible(&mousedev_table_mutex); 550 - if (error) 550 + if (error) { 551 + unlock_kernel(); 551 552 return error; 553 + } 552 554 mousedev = mousedev_table[i]; 553 555 if (mousedev) 554 556 get_device(&mousedev->dev); 555 557 mutex_unlock(&mousedev_table_mutex); 556 558 557 - if (!mousedev) 559 + if (!mousedev) { 560 + unlock_kernel(); 558 561 return -ENODEV; 562 + } 559 563 560 564 client = kzalloc(sizeof(struct mousedev_client), GFP_KERNEL); 561 565 if (!client) { ··· 579 573 goto err_free_client; 580 574 581 575 file->private_data = client; 576 + unlock_kernel(); 582 577 return 0; 583 578 584 579 err_free_client: ··· 587 580 kfree(client); 588 581 err_put_mousedev: 589 582 put_device(&mousedev->dev); 583 + unlock_kernel(); 590 584 return error; 591 585 } 592 586
+5 -1
drivers/input/serio/serio_raw.c
··· 10 10 */ 11 11 12 12 #include <linux/slab.h> 13 + #include <linux/smp_lock.h> 13 14 #include <linux/poll.h> 14 15 #include <linux/module.h> 15 16 #include <linux/serio.h> ··· 82 81 struct serio_raw_list *list; 83 82 int retval = 0; 84 83 84 + lock_kernel(); 85 85 retval = mutex_lock_interruptible(&serio_raw_mutex); 86 86 if (retval) 87 - return retval; 87 + goto out_bkl; 88 88 89 89 if (!(serio_raw = serio_raw_locate(iminor(inode)))) { 90 90 retval = -ENODEV; ··· 110 108 111 109 out: 112 110 mutex_unlock(&serio_raw_mutex); 111 + out_bkl: 112 + unlock_kernel(); 113 113 return retval; 114 114 } 115 115
+11 -6
drivers/isdn/capi/capi.c
··· 20 20 #include <linux/signal.h> 21 21 #include <linux/mutex.h> 22 22 #include <linux/mm.h> 23 + #include <linux/smp_lock.h> 23 24 #include <linux/timer.h> 24 25 #include <linux/wait.h> 25 26 #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE ··· 984 983 static int 985 984 capi_open(struct inode *inode, struct file *file) 986 985 { 986 + int ret; 987 + 988 + lock_kernel(); 987 989 if (file->private_data) 988 - return -EEXIST; 989 - 990 - if ((file->private_data = capidev_alloc()) == NULL) 991 - return -ENOMEM; 992 - 993 - return nonseekable_open(inode, file); 990 + ret = -EEXIST; 991 + else if ((file->private_data = capidev_alloc()) == NULL) 992 + ret = -ENOMEM; 993 + else 994 + ret = nonseekable_open(inode, file); 995 + unlock_kernel(); 996 + return ret; 994 997 } 995 998 996 999 static int
+11 -5
drivers/isdn/hardware/eicon/divamnt.c
··· 14 14 #include <linux/init.h> 15 15 #include <linux/kernel.h> 16 16 #include <linux/poll.h> 17 + #include <linux/smp_lock.h> 17 18 #include <asm/uaccess.h> 18 19 19 20 #include "platform.h" ··· 128 127 129 128 static int maint_open(struct inode *ino, struct file *filep) 130 129 { 130 + int ret; 131 + 132 + lock_kernel(); 131 133 /* only one open is allowed, so we test 132 134 it atomically */ 133 135 if (test_and_set_bit(0, &opened)) 134 - return (-EBUSY); 135 - 136 - filep->private_data = NULL; 137 - 138 - return nonseekable_open(ino, filep); 136 + ret = -EBUSY; 137 + else { 138 + filep->private_data = NULL; 139 + ret = nonseekable_open(ino, filep); 140 + } 141 + unlock_kernel(); 142 + return ret; 139 143 } 140 144 141 145 static int maint_close(struct inode *ino, struct file *filep)
+2
drivers/isdn/hardware/eicon/divasi.c
··· 17 17 #include <linux/poll.h> 18 18 #include <linux/proc_fs.h> 19 19 #include <linux/skbuff.h> 20 + #include <linux/smp_lock.h> 20 21 #include <asm/uaccess.h> 21 22 22 23 #include "platform.h" ··· 401 400 402 401 static int um_idi_open(struct inode *inode, struct file *file) 403 402 { 403 + cycle_kernel_lock(); 404 404 return (0); 405 405 } 406 406
+2
drivers/isdn/hardware/eicon/divasmain.c
··· 21 21 #include <linux/list.h> 22 22 #include <linux/poll.h> 23 23 #include <linux/kmod.h> 24 + #include <linux/smp_lock.h> 24 25 25 26 #include "platform.h" 26 27 #undef ID_MASK ··· 581 580 */ 582 581 static int divas_open(struct inode *inode, struct file *file) 583 582 { 583 + cycle_kernel_lock(); 584 584 return (0); 585 585 } 586 586
+2 -1
drivers/isdn/i4l/isdn_common.c
··· 1732 1732 int chidx; 1733 1733 int retval = -ENODEV; 1734 1734 1735 - 1735 + lock_kernel(); 1736 1736 if (minor == ISDN_MINOR_STATUS) { 1737 1737 infostruct *p; 1738 1738 ··· 1783 1783 #endif 1784 1784 out: 1785 1785 nonseekable_open(ino, filep); 1786 + unlock_kernel(); 1786 1787 return retval; 1787 1788 } 1788 1789
+13 -5
drivers/macintosh/adb.c
··· 644 644 static int adb_open(struct inode *inode, struct file *file) 645 645 { 646 646 struct adbdev_state *state; 647 + int ret = 0; 647 648 648 - if (iminor(inode) > 0 || adb_controller == NULL) 649 - return -ENXIO; 649 + lock_kernel(); 650 + if (iminor(inode) > 0 || adb_controller == NULL) { 651 + ret = -ENXIO; 652 + goto out; 653 + } 650 654 state = kmalloc(sizeof(struct adbdev_state), GFP_KERNEL); 651 - if (state == 0) 652 - return -ENOMEM; 655 + if (state == 0) { 656 + ret = -ENOMEM; 657 + goto out; 658 + } 653 659 file->private_data = state; 654 660 spin_lock_init(&state->lock); 655 661 atomic_set(&state->n_pending, 0); ··· 663 657 init_waitqueue_head(&state->wait_queue); 664 658 state->inuse = 1; 665 659 666 - return 0; 660 + out: 661 + unlock_kernel(); 662 + return ret; 667 663 } 668 664 669 665 static int adb_release(struct inode *inode, struct file *file)
+2
drivers/macintosh/ans-lcd.c
··· 3 3 */ 4 4 5 5 #include <linux/types.h> 6 + #include <linux/smp_lock.h> 6 7 #include <linux/errno.h> 7 8 #include <linux/kernel.h> 8 9 #include <linux/miscdevice.h> ··· 120 119 static int 121 120 anslcd_open( struct inode * inode, struct file * file ) 122 121 { 122 + cycle_kernel_lock(); 123 123 return 0; 124 124 } 125 125
+3
drivers/macintosh/smu.c
··· 19 19 * the userland interface 20 20 */ 21 21 22 + #include <linux/smp_lock.h> 22 23 #include <linux/types.h> 23 24 #include <linux/kernel.h> 24 25 #include <linux/device.h> ··· 1087 1086 pp->mode = smu_file_commands; 1088 1087 init_waitqueue_head(&pp->wait); 1089 1088 1089 + lock_kernel(); 1090 1090 spin_lock_irqsave(&smu_clist_lock, flags); 1091 1091 list_add(&pp->list, &smu_clist); 1092 1092 spin_unlock_irqrestore(&smu_clist_lock, flags); 1093 1093 file->private_data = pp; 1094 + unlock_kernel(); 1094 1095 1095 1096 return 0; 1096 1097 }
+3
drivers/macintosh/via-pmu.c
··· 18 18 * 19 19 */ 20 20 #include <stdarg.h> 21 + #include <linux/smp_lock.h> 21 22 #include <linux/types.h> 22 23 #include <linux/errno.h> 23 24 #include <linux/kernel.h> ··· 2048 2047 pp->rb_get = pp->rb_put = 0; 2049 2048 spin_lock_init(&pp->lock); 2050 2049 init_waitqueue_head(&pp->wait); 2050 + lock_kernel(); 2051 2051 spin_lock_irqsave(&all_pvt_lock, flags); 2052 2052 #if defined(CONFIG_INPUT_ADBHID) && defined(CONFIG_PMAC_BACKLIGHT) 2053 2053 pp->backlight_locker = 0; ··· 2056 2054 list_add(&pp->list, &all_pmu_pvt); 2057 2055 spin_unlock_irqrestore(&all_pvt_lock, flags); 2058 2056 file->private_data = pp; 2057 + unlock_kernel(); 2059 2058 return 0; 2060 2059 } 2061 2060
+4
drivers/media/dvb/dvb-core/dvbdev.c
··· 32 32 #include <linux/fs.h> 33 33 #include <linux/cdev.h> 34 34 #include <linux/mutex.h> 35 + #include <linux/smp_lock.h> 35 36 #include "dvbdev.h" 36 37 37 38 static int dvbdev_debug; ··· 75 74 { 76 75 struct dvb_device *dvbdev; 77 76 77 + lock_kernel(); 78 78 dvbdev = dvbdev_find_device (iminor(inode)); 79 79 80 80 if (dvbdev && dvbdev->fops) { ··· 92 90 file->f_op = fops_get(old_fops); 93 91 } 94 92 fops_put(old_fops); 93 + unlock_kernel(); 95 94 return err; 96 95 } 96 + unlock_kernel(); 97 97 return -ENODEV; 98 98 } 99 99
+4
drivers/media/radio/miropcm20-rds.c
··· 12 12 #include <linux/module.h> 13 13 #include <linux/init.h> 14 14 #include <linux/slab.h> 15 + #include <linux/smp_lock.h> 15 16 #include <linux/fs.h> 16 17 #include <linux/miscdevice.h> 17 18 #include <linux/delay.h> ··· 28 27 if (rds_users) 29 28 return -EBUSY; 30 29 30 + lock_kernel(); 31 31 rds_users++; 32 32 if ((text_buffer=kmalloc(66, GFP_KERNEL)) == 0) { 33 33 rds_users--; 34 34 printk(KERN_NOTICE "aci-rds: Out of memory by open()...\n"); 35 + unlock_kernel(); 35 36 return -ENOMEM; 36 37 } 37 38 39 + unlock_kernel(); 38 40 return 0; 39 41 } 40 42
+4
drivers/media/video/videodev.c
··· 36 36 #include <linux/init.h> 37 37 #include <linux/kmod.h> 38 38 #include <linux/slab.h> 39 + #include <linux/smp_lock.h> 39 40 #include <asm/uaccess.h> 40 41 #include <asm/system.h> 41 42 ··· 443 442 444 443 if(minor>=VIDEO_NUM_DEVICES) 445 444 return -ENODEV; 445 + lock_kernel(); 446 446 mutex_lock(&videodev_lock); 447 447 vfl=video_device[minor]; 448 448 if(vfl==NULL) { ··· 453 451 vfl=video_device[minor]; 454 452 if (vfl==NULL) { 455 453 mutex_unlock(&videodev_lock); 454 + unlock_kernel(); 456 455 return -ENODEV; 457 456 } 458 457 } ··· 467 464 } 468 465 fops_put(old_fops); 469 466 mutex_unlock(&videodev_lock); 467 + unlock_kernel(); 470 468 return err; 471 469 } 472 470
+5 -1
drivers/message/fusion/mptctl.c
··· 548 548 mptctl_fasync(int fd, struct file *filep, int mode) 549 549 { 550 550 MPT_ADAPTER *ioc; 551 + int ret; 551 552 553 + lock_kernel(); 552 554 list_for_each_entry(ioc, &ioc_list, list) 553 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 562 static int
+8 -4
drivers/message/i2o/i2o_config.c
··· 1061 1061 if (!tmp) 1062 1062 return -ENOMEM; 1063 1063 1064 + lock_kernel(); 1064 1065 file->private_data = (void *)(i2o_cfg_info_id++); 1065 1066 tmp->fp = file; 1066 1067 tmp->fasync = NULL; ··· 1075 1074 spin_lock_irqsave(&i2o_config_lock, flags); 1076 1075 open_files = tmp; 1077 1076 spin_unlock_irqrestore(&i2o_config_lock, flags); 1077 + unlock_kernel(); 1078 1078 1079 1079 return 0; 1080 1080 } ··· 1084 1082 { 1085 1083 ulong id = (ulong) fp->private_data; 1086 1084 struct i2o_cfg_info *p; 1085 + int ret = -EBADF; 1087 1086 1087 + lock_kernel(); 1088 1088 for (p = open_files; p; p = p->next) 1089 1089 if (p->q_id == id) 1090 1090 break; 1091 1091 1092 - if (!p) 1093 - return -EBADF; 1094 - 1095 - return fasync_helper(fd, fp, on, &p->fasync); 1092 + if (p) 1093 + ret = fasync_helper(fd, fp, on, &p->fasync); 1094 + unlock_kernel(); 1095 + return ret; 1096 1096 } 1097 1097 1098 1098 static int cfg_release(struct inode *inode, struct file *file)
+8 -1
drivers/misc/hdpuftrs/hdpu_cpustate.c
··· 17 17 #include <linux/module.h> 18 18 #include <linux/kernel.h> 19 19 #include <linux/spinlock.h> 20 + #include <linux/smp_lock.h> 20 21 #include <linux/miscdevice.h> 21 22 #include <linux/proc_fs.h> 22 23 #include <linux/hdpu_features.h> ··· 152 151 153 152 static int cpustate_open(struct inode *inode, struct file *file) 154 153 { 155 - return cpustate_get_ref((file->f_flags & O_EXCL)); 154 + int ret; 155 + 156 + lock_kernel(); 157 + ret = cpustate_get_ref((file->f_flags & O_EXCL)); 158 + unlock_kernel(); 159 + 160 + return ret; 156 161 } 157 162 158 163 static int cpustate_release(struct inode *inode, struct file *file)
+7 -2
drivers/misc/phantom.c
··· 22 22 #include <linux/interrupt.h> 23 23 #include <linux/cdev.h> 24 24 #include <linux/phantom.h> 25 + #include <linux/smp_lock.h> 25 26 26 27 #include <asm/atomic.h> 27 28 #include <asm/io.h> ··· 213 212 struct phantom_device *dev = container_of(inode->i_cdev, 214 213 struct phantom_device, cdev); 215 214 215 + lock_kernel(); 216 216 nonseekable_open(inode, file); 217 217 218 - if (mutex_lock_interruptible(&dev->open_lock)) 218 + if (mutex_lock_interruptible(&dev->open_lock)) { 219 + unlock_kernel(); 219 220 return -ERESTARTSYS; 221 + } 220 222 221 223 if (dev->opened) { 222 224 mutex_unlock(&dev->open_lock); 225 + unlock_kernel(); 223 226 return -EINVAL; 224 227 } 225 228 ··· 234 229 atomic_set(&dev->counter, 0); 235 230 dev->opened++; 236 231 mutex_unlock(&dev->open_lock); 237 - 232 + unlock_kernel(); 238 233 return 0; 239 234 } 240 235
+3
drivers/misc/sony-laptop.c
··· 46 46 #include <linux/module.h> 47 47 #include <linux/moduleparam.h> 48 48 #include <linux/init.h> 49 + #include <linux/smp_lock.h> 49 50 #include <linux/types.h> 50 51 #include <linux/backlight.h> 51 52 #include <linux/platform_device.h> ··· 1928 1927 static int sonypi_misc_open(struct inode *inode, struct file *file) 1929 1928 { 1930 1929 /* Flush input queue on first open */ 1930 + lock_kernel(); 1931 1931 if (atomic_inc_return(&sonypi_compat.open_count) == 1) 1932 1932 kfifo_reset(sonypi_compat.fifo); 1933 + unlock_kernel(); 1933 1934 return 0; 1934 1935 } 1935 1936
+16 -6
drivers/mtd/mtdchar.c
··· 14 14 #include <linux/module.h> 15 15 #include <linux/slab.h> 16 16 #include <linux/sched.h> 17 + #include <linux/smp_lock.h> 17 18 18 19 #include <linux/mtd/mtd.h> 19 20 #include <linux/mtd/compatmac.h> ··· 87 86 { 88 87 int minor = iminor(inode); 89 88 int devnum = minor >> 1; 89 + int ret = 0; 90 90 struct mtd_info *mtd; 91 91 struct mtd_file_info *mfi; 92 92 ··· 100 98 if ((file->f_mode & 2) && (minor & 1)) 101 99 return -EACCES; 102 100 101 + lock_kernel(); 103 102 mtd = get_mtd_device(NULL, devnum); 104 103 105 - if (IS_ERR(mtd)) 106 - return PTR_ERR(mtd); 104 + if (IS_ERR(mtd)) { 105 + ret = PTR_ERR(mtd); 106 + goto out; 107 + } 107 108 108 109 if (MTD_ABSENT == mtd->type) { 109 110 put_mtd_device(mtd); 110 - return -ENODEV; 111 + ret = -ENODEV; 112 + goto out; 111 113 } 112 114 113 115 /* You can't open it RW if it's not a writeable device */ 114 116 if ((file->f_mode & 2) && !(mtd->flags & MTD_WRITEABLE)) { 115 117 put_mtd_device(mtd); 116 - return -EACCES; 118 + ret = -EACCES; 119 + goto out; 117 120 } 118 121 119 122 mfi = kzalloc(sizeof(*mfi), GFP_KERNEL); 120 123 if (!mfi) { 121 124 put_mtd_device(mtd); 122 - return -ENOMEM; 125 + ret = -ENOMEM; 126 + goto out; 123 127 } 124 128 mfi->mtd = mtd; 125 129 file->private_data = mfi; 126 130 127 - return 0; 131 + out: 132 + unlock_kernel(); 133 + return ret; 128 134 } /* mtd_open */ 129 135 130 136 /*====================================================================*/
+6 -1
drivers/mtd/ubi/cdev.c
··· 39 39 #include <linux/stat.h> 40 40 #include <linux/ioctl.h> 41 41 #include <linux/capability.h> 42 + #include <linux/smp_lock.h> 42 43 #include <mtd/ubi-user.h> 43 44 #include <asm/uaccess.h> 44 45 #include <asm/div64.h> ··· 104 103 struct ubi_volume_desc *desc; 105 104 int vol_id = iminor(inode) - 1, mode, ubi_num; 106 105 106 + lock_kernel(); 107 107 ubi_num = ubi_major2num(imajor(inode)); 108 - if (ubi_num < 0) 108 + if (ubi_num < 0) { 109 + unlock_kernel(); 109 110 return ubi_num; 111 + } 110 112 111 113 if (file->f_mode & FMODE_WRITE) 112 114 mode = UBI_READWRITE; ··· 119 115 dbg_msg("open volume %d, mode %d", vol_id, mode); 120 116 121 117 desc = ubi_open_volume(ubi_num, vol_id, mode); 118 + unlock_kernel(); 122 119 if (IS_ERR(desc)) 123 120 return PTR_ERR(desc); 124 121
+2
drivers/net/ppp_generic.c
··· 39 39 #include <linux/if_arp.h> 40 40 #include <linux/ip.h> 41 41 #include <linux/tcp.h> 42 + #include <linux/smp_lock.h> 42 43 #include <linux/spinlock.h> 43 44 #include <linux/rwsem.h> 44 45 #include <linux/stddef.h> ··· 354 353 */ 355 354 static int ppp_open(struct inode *inode, struct file *file) 356 355 { 356 + cycle_kernel_lock(); 357 357 /* 358 358 * This could (should?) be enforced by the permissions on /dev/ppp. 359 359 */
+9 -4
drivers/net/tun.c
··· 48 48 #include <linux/kernel.h> 49 49 #include <linux/major.h> 50 50 #include <linux/slab.h> 51 + #include <linux/smp_lock.h> 51 52 #include <linux/poll.h> 52 53 #include <linux/fcntl.h> 53 54 #include <linux/init.h> ··· 803 802 804 803 DBG(KERN_INFO "%s: tun_chr_fasync %d\n", tun->dev->name, on); 805 804 805 + lock_kernel(); 806 806 if ((ret = fasync_helper(fd, file, on, &tun->fasync)) < 0) 807 - return ret; 807 + goto out; 808 808 809 809 if (on) { 810 810 ret = __f_setown(file, task_pid(current), PIDTYPE_PID, 0); 811 811 if (ret) 812 - return ret; 812 + goto out; 813 813 tun->flags |= TUN_FASYNC; 814 814 } else 815 815 tun->flags &= ~TUN_FASYNC; 816 - 817 - return 0; 816 + ret = 0; 817 + out: 818 + unlock_kernel(); 819 + return ret; 818 820 } 819 821 820 822 static int tun_chr_open(struct inode *inode, struct file * file) 821 823 { 824 + cycle_kernel_lock(); 822 825 DBG1(KERN_INFO "tunX: tun_chr_open\n"); 823 826 file->private_data = NULL; 824 827 return 0;
+16 -6
drivers/net/wan/cosa.c
··· 92 92 #include <linux/spinlock.h> 93 93 #include <linux/mutex.h> 94 94 #include <linux/device.h> 95 + #include <linux/smp_lock.h> 95 96 96 97 #undef COSA_SLOW_IO /* for testing purposes only */ 97 98 ··· 971 970 struct channel_data *chan; 972 971 unsigned long flags; 973 972 int n; 973 + int ret = 0; 974 974 975 + lock_kernel(); 975 976 if ((n=iminor(file->f_path.dentry->d_inode)>>CARD_MINOR_BITS) 976 - >= nr_cards) 977 - return -ENODEV; 977 + >= nr_cards) { 978 + ret = -ENODEV; 979 + goto out; 980 + } 978 981 cosa = cosa_cards+n; 979 982 980 983 if ((n=iminor(file->f_path.dentry->d_inode) 981 - & ((1<<CARD_MINOR_BITS)-1)) >= cosa->nchannels) 982 - return -ENODEV; 984 + & ((1<<CARD_MINOR_BITS)-1)) >= cosa->nchannels) { 985 + ret = -ENODEV; 986 + goto out; 987 + } 983 988 chan = cosa->chan + n; 984 989 985 990 file->private_data = chan; ··· 994 987 995 988 if (chan->usage < 0) { /* in netdev mode */ 996 989 spin_unlock_irqrestore(&cosa->lock, flags); 997 - return -EBUSY; 990 + ret = -EBUSY; 991 + goto out; 998 992 } 999 993 cosa->usage++; 1000 994 chan->usage++; ··· 1004 996 chan->setup_rx = chrdev_setup_rx; 1005 997 chan->rx_done = chrdev_rx_done; 1006 998 spin_unlock_irqrestore(&cosa->lock, flags); 1007 - return 0; 999 + out: 1000 + unlock_kernel(); 1001 + return ret; 1008 1002 } 1009 1003 1010 1004 static int cosa_release(struct inode *inode, struct file *file)
+3
drivers/parisc/eisa_eeprom.c
··· 24 24 #include <linux/kernel.h> 25 25 #include <linux/miscdevice.h> 26 26 #include <linux/slab.h> 27 + #include <linux/smp_lock.h> 27 28 #include <linux/fs.h> 28 29 #include <asm/io.h> 29 30 #include <asm/uaccess.h> ··· 84 83 85 84 static int eisa_eeprom_open(struct inode *inode, struct file *file) 86 85 { 86 + cycle_kernel_lock(); 87 + 87 88 if (file->f_mode & 2) 88 89 return -EINVAL; 89 90
+18 -7
drivers/pcmcia/pcmcia_ioctl.c
··· 27 27 #include <linux/proc_fs.h> 28 28 #include <linux/poll.h> 29 29 #include <linux/pci.h> 30 + #include <linux/smp_lock.h> 30 31 #include <linux/workqueue.h> 31 32 32 33 #include <pcmcia/cs_types.h> ··· 546 545 struct pcmcia_socket *s; 547 546 user_info_t *user; 548 547 static int warning_printed = 0; 548 + int ret = 0; 549 549 550 550 ds_dbg(0, "ds_open(socket %d)\n", i); 551 551 552 + lock_kernel(); 552 553 s = pcmcia_get_socket_by_nr(i); 553 - if (!s) 554 - return -ENODEV; 554 + if (!s) { 555 + ret = -ENODEV; 556 + goto out; 557 + } 555 558 s = pcmcia_get_socket(s); 556 - if (!s) 557 - return -ENODEV; 559 + if (!s) { 560 + ret = -ENODEV; 561 + goto out; 562 + } 558 563 559 564 if ((file->f_flags & O_ACCMODE) != O_RDONLY) { 560 565 if (s->pcmcia_state.busy) { 561 566 pcmcia_put_socket(s); 562 - return -EBUSY; 567 + ret = -EBUSY; 568 + goto out; 563 569 } 564 570 else 565 571 s->pcmcia_state.busy = 1; ··· 575 567 user = kmalloc(sizeof(user_info_t), GFP_KERNEL); 576 568 if (!user) { 577 569 pcmcia_put_socket(s); 578 - return -ENOMEM; 570 + ret = -ENOMEM; 571 + goto out; 579 572 } 580 573 user->event_tail = user->event_head = 0; 581 574 user->next = s->user; ··· 598 589 599 590 if (s->pcmcia_state.present) 600 591 queue_event(user, CS_EVENT_CARD_INSERTION); 601 - return 0; 592 + out: 593 + unlock_kernel(); 594 + return ret; 602 595 } /* ds_open */ 603 596 604 597 /*====================================================================*/
+9 -3
drivers/rtc/rtc-dev.c
··· 13 13 14 14 #include <linux/module.h> 15 15 #include <linux/rtc.h> 16 + #include <linux/smp_lock.h> 16 17 #include "rtc-core.h" 17 18 18 19 static dev_t rtc_devt; ··· 27 26 struct rtc_device, char_dev); 28 27 const struct rtc_class_ops *ops = rtc->ops; 29 28 30 - if (test_and_set_bit_lock(RTC_DEV_BUSY, &rtc->flags)) 31 - return -EBUSY; 29 + lock_kernel(); 30 + if (test_and_set_bit_lock(RTC_DEV_BUSY, &rtc->flags)) { 31 + err = -EBUSY; 32 + goto out; 33 + } 32 34 33 35 file->private_data = rtc; 34 36 ··· 41 37 rtc->irq_data = 0; 42 38 spin_unlock_irq(&rtc->irq_lock); 43 39 44 - return 0; 40 + goto out; 45 41 } 46 42 47 43 /* something has gone wrong */ 48 44 clear_bit_unlock(RTC_DEV_BUSY, &rtc->flags); 45 + out: 46 + unlock_kernel(); 49 47 return err; 50 48 } 51 49
+6 -1
drivers/rtc/rtc-m41t80.c
··· 17 17 #include <linux/init.h> 18 18 #include <linux/kernel.h> 19 19 #include <linux/slab.h> 20 + #include <linux/smp_lock.h> 20 21 #include <linux/string.h> 21 22 #include <linux/i2c.h> 22 23 #include <linux/rtc.h> ··· 656 655 static int wdt_open(struct inode *inode, struct file *file) 657 656 { 658 657 if (MINOR(inode->i_rdev) == WATCHDOG_MINOR) { 659 - if (test_and_set_bit(0, &wdt_is_open)) 658 + lock_kernel(); 659 + if (test_and_set_bit(0, &wdt_is_open)) { 660 + unlock_kernel(); 660 661 return -EBUSY; 662 + } 661 663 /* 662 664 * Activate 663 665 */ 664 666 wdt_is_open = 1; 667 + unlock_kernel(); 665 668 return 0; 666 669 } 667 670 return -ENODEV;
+6
drivers/s390/block/dasd_eer.c
··· 15 15 #include <linux/device.h> 16 16 #include <linux/poll.h> 17 17 #include <linux/mutex.h> 18 + #include <linux/smp_lock.h> 18 19 19 20 #include <asm/uaccess.h> 20 21 #include <asm/atomic.h> ··· 526 525 eerb = kzalloc(sizeof(struct eerbuffer), GFP_KERNEL); 527 526 if (!eerb) 528 527 return -ENOMEM; 528 + lock_kernel(); 529 529 eerb->buffer_page_count = eer_pages; 530 530 if (eerb->buffer_page_count < 1 || 531 531 eerb->buffer_page_count > INT_MAX / PAGE_SIZE) { ··· 534 532 MESSAGE(KERN_WARNING, "can't open device since module " 535 533 "parameter eer_pages is smaller then 1 or" 536 534 " bigger then %d", (int)(INT_MAX / PAGE_SIZE)); 535 + unlock_kernel(); 537 536 return -EINVAL; 538 537 } 539 538 eerb->buffersize = eerb->buffer_page_count * PAGE_SIZE; ··· 542 539 GFP_KERNEL); 543 540 if (!eerb->buffer) { 544 541 kfree(eerb); 542 + unlock_kernel(); 545 543 return -ENOMEM; 546 544 } 547 545 if (dasd_eer_allocate_buffer_pages(eerb->buffer, 548 546 eerb->buffer_page_count)) { 549 547 kfree(eerb->buffer); 550 548 kfree(eerb); 549 + unlock_kernel(); 551 550 return -ENOMEM; 552 551 } 553 552 filp->private_data = eerb; ··· 557 552 list_add(&eerb->list, &bufferlist); 558 553 spin_unlock_irqrestore(&bufferlock, flags); 559 554 555 + unlock_kernel(); 560 556 return nonseekable_open(inp,filp); 561 557 } 562 558
+16 -7
drivers/s390/char/fs3270.c
··· 14 14 #include <linux/interrupt.h> 15 15 #include <linux/list.h> 16 16 #include <linux/types.h> 17 + #include <linux/smp_lock.h> 17 18 18 19 #include <asm/ccwdev.h> 19 20 #include <asm/cio.h> ··· 422 421 423 422 if (imajor(filp->f_path.dentry->d_inode) != IBM_FS3270_MAJOR) 424 423 return -ENODEV; 424 + lock_kernel(); 425 425 minor = iminor(filp->f_path.dentry->d_inode); 426 426 /* Check for minor 0 multiplexer. */ 427 427 if (minor == 0) { ··· 431 429 tty = get_current_tty(); 432 430 if (!tty || tty->driver->major != IBM_TTY3270_MAJOR) { 433 431 mutex_unlock(&tty_mutex); 434 - return -ENODEV; 432 + rc = -ENODEV; 433 + goto out; 435 434 } 436 435 minor = tty->index + RAW3270_FIRSTMINOR; 437 436 mutex_unlock(&tty_mutex); ··· 441 438 fp = (struct fs3270 *) raw3270_find_view(&fs3270_fn, minor); 442 439 if (!IS_ERR(fp)) { 443 440 raw3270_put_view(&fp->view); 444 - return -EBUSY; 441 + rc = -EBUSY; 442 + goto out; 445 443 } 446 444 /* Allocate fullscreen view structure. */ 447 445 fp = fs3270_alloc_view(); 448 - if (IS_ERR(fp)) 449 - return PTR_ERR(fp); 446 + if (IS_ERR(fp)) { 447 + rc = PTR_ERR(fp); 448 + goto out; 449 + } 450 450 451 451 init_waitqueue_head(&fp->wait); 452 452 fp->fs_pid = get_pid(task_pid(current)); 453 453 rc = raw3270_add_view(&fp->view, &fs3270_fn, minor); 454 454 if (rc) { 455 455 fs3270_free_view(&fp->view); 456 - return rc; 456 + goto out; 457 457 } 458 458 459 459 /* Allocate idal-buffer. */ ··· 464 458 if (IS_ERR(ib)) { 465 459 raw3270_put_view(&fp->view); 466 460 raw3270_del_view(&fp->view); 467 - return PTR_ERR(fp); 461 + rc = PTR_ERR(fp); 462 + goto out; 468 463 } 469 464 fp->rdbuf = ib; 470 465 ··· 473 466 if (rc) { 474 467 raw3270_put_view(&fp->view); 475 468 raw3270_del_view(&fp->view); 476 - return rc; 469 + goto out; 477 470 } 478 471 filp->private_data = fp; 472 + out: 473 + unlock_kernel(); 479 474 return 0; 480 475 } 481 476
+4
drivers/s390/char/monreader.c
··· 10 10 #include <linux/module.h> 11 11 #include <linux/moduleparam.h> 12 12 #include <linux/init.h> 13 + #include <linux/smp_lock.h> 13 14 #include <linux/errno.h> 14 15 #include <linux/types.h> 15 16 #include <linux/kernel.h> ··· 292 291 /* 293 292 * only one user allowed 294 293 */ 294 + lock_kernel(); 295 295 rc = -EBUSY; 296 296 if (test_and_set_bit(MON_IN_USE, &mon_in_use)) 297 297 goto out; ··· 329 327 goto out_path; 330 328 } 331 329 filp->private_data = monpriv; 330 + unlock_kernel(); 332 331 return nonseekable_open(inode, filp); 333 332 334 333 out_path: ··· 339 336 out_use: 340 337 clear_bit(MON_IN_USE, &mon_in_use); 341 338 out: 339 + unlock_kernel(); 342 340 return rc; 343 341 } 344 342
+3
drivers/s390/char/monwriter.c
··· 12 12 #include <linux/moduleparam.h> 13 13 #include <linux/init.h> 14 14 #include <linux/errno.h> 15 + #include <linux/smp_lock.h> 15 16 #include <linux/types.h> 16 17 #include <linux/kernel.h> 17 18 #include <linux/miscdevice.h> ··· 180 179 monpriv = kzalloc(sizeof(struct mon_private), GFP_KERNEL); 181 180 if (!monpriv) 182 181 return -ENOMEM; 182 + lock_kernel(); 183 183 INIT_LIST_HEAD(&monpriv->list); 184 184 monpriv->hdr_to_read = sizeof(monpriv->hdr); 185 185 mutex_init(&monpriv->thread_mutex); 186 186 filp->private_data = monpriv; 187 + unlock_kernel(); 187 188 return nonseekable_open(inode, filp); 188 189 } 189 190
+9 -3
drivers/s390/char/tape_char.c
··· 14 14 #include <linux/types.h> 15 15 #include <linux/proc_fs.h> 16 16 #include <linux/mtio.h> 17 + #include <linux/smp_lock.h> 17 18 18 19 #include <asm/uaccess.h> 19 20 ··· 290 289 if (imajor(filp->f_path.dentry->d_inode) != tapechar_major) 291 290 return -ENODEV; 292 291 292 + lock_kernel(); 293 293 minor = iminor(filp->f_path.dentry->d_inode); 294 294 device = tape_get_device(minor / TAPE_MINORS_PER_DEV); 295 295 if (IS_ERR(device)) { 296 296 DBF_EVENT(3, "TCHAR:open: tape_get_device() failed\n"); 297 - return PTR_ERR(device); 297 + rc = PTR_ERR(device); 298 + goto out; 298 299 } 299 300 300 301 301 302 rc = tape_open(device); 302 303 if (rc == 0) { 303 304 filp->private_data = device; 304 - return nonseekable_open(inode, filp); 305 + rc = nonseekable_open(inode, filp); 305 306 } 306 - tape_put_device(device); 307 + else 308 + tape_put_device(device); 307 309 310 + out: 311 + unlock_kernel(); 308 312 return rc; 309 313 } 310 314
+4
drivers/s390/char/vmcp.c
··· 16 16 #include <linux/kernel.h> 17 17 #include <linux/miscdevice.h> 18 18 #include <linux/module.h> 19 + #include <linux/smp_lock.h> 19 20 #include <asm/cpcmd.h> 20 21 #include <asm/debug.h> 21 22 #include <asm/uaccess.h> ··· 40 39 session = kmalloc(sizeof(*session), GFP_KERNEL); 41 40 if (!session) 42 41 return -ENOMEM; 42 + 43 + lock_kernel(); 43 44 session->bufsize = PAGE_SIZE; 44 45 session->response = NULL; 45 46 session->resp_size = 0; 46 47 mutex_init(&session->mutex); 47 48 file->private_data = session; 49 + unlock_kernel(); 48 50 return nonseekable_open(inode, file); 49 51 } 50 52
+7 -1
drivers/s390/char/vmlogrdr.c
··· 25 25 #include <linux/kmod.h> 26 26 #include <linux/cdev.h> 27 27 #include <linux/device.h> 28 + #include <linux/smp_lock.h> 28 29 #include <linux/string.h> 29 30 30 31 ··· 311 310 return -ENOSYS; 312 311 313 312 /* Besure this device hasn't already been opened */ 313 + lock_kernel(); 314 314 spin_lock_bh(&logptr->priv_lock); 315 315 if (logptr->dev_in_use) { 316 316 spin_unlock_bh(&logptr->priv_lock); 317 + unlock_kernel(); 317 318 return -EBUSY; 318 319 } 319 320 logptr->dev_in_use = 1; ··· 359 356 || (logptr->iucv_path_severed)); 360 357 if (logptr->iucv_path_severed) 361 358 goto out_record; 362 - return nonseekable_open(inode, filp); 359 + ret = nonseekable_open(inode, filp); 360 + unlock_kernel(); 361 + return ret; 363 362 364 363 out_record: 365 364 if (logptr->autorecording) ··· 371 366 logptr->path = NULL; 372 367 out_dev: 373 368 logptr->dev_in_use = 0; 369 + unlock_kernel(); 374 370 return -EIO; 375 371 } 376 372
+9 -3
drivers/s390/char/vmur.c
··· 9 9 */ 10 10 11 11 #include <linux/cdev.h> 12 + #include <linux/smp_lock.h> 12 13 13 14 #include <asm/uaccess.h> 14 15 #include <asm/cio.h> ··· 670 669 671 670 if (accmode == O_RDWR) 672 671 return -EACCES; 673 - 672 + lock_kernel(); 674 673 /* 675 674 * We treat the minor number as the devno of the ur device 676 675 * to find in the driver tree. ··· 678 677 devno = MINOR(file->f_dentry->d_inode->i_rdev); 679 678 680 679 urd = urdev_get_from_devno(devno); 681 - if (!urd) 682 - return -ENXIO; 680 + if (!urd) { 681 + rc = -ENXIO; 682 + goto out; 683 + } 683 684 684 685 spin_lock(&urd->open_lock); 685 686 while (urd->open_flag) { ··· 724 721 goto fail_urfile_free; 725 722 urf->file_reclen = rc; 726 723 file->private_data = urf; 724 + unlock_kernel(); 727 725 return 0; 728 726 729 727 fail_urfile_free: ··· 735 731 spin_unlock(&urd->open_lock); 736 732 fail_put: 737 733 urdev_put(urd); 734 + out: 735 + unlock_kernel(); 738 736 return rc; 739 737 } 740 738
+6 -1
drivers/s390/char/vmwatchdog.c
··· 13 13 #include <linux/module.h> 14 14 #include <linux/moduleparam.h> 15 15 #include <linux/watchdog.h> 16 + #include <linux/smp_lock.h> 16 17 17 18 #include <asm/ebcdic.h> 18 19 #include <asm/io.h> ··· 122 121 static int vmwdt_open(struct inode *i, struct file *f) 123 122 { 124 123 int ret; 125 - if (test_and_set_bit(0, &vmwdt_is_open)) 124 + lock_kernel(); 125 + if (test_and_set_bit(0, &vmwdt_is_open)) { 126 + unlock_kernel(); 126 127 return -EBUSY; 128 + } 127 129 ret = vmwdt_keepalive(); 128 130 if (ret) 129 131 clear_bit(0, &vmwdt_is_open); 132 + unlock_kernel(); 130 133 return ret ? ret : nonseekable_open(i, f); 131 134 } 132 135
+3
drivers/s390/crypto/zcrypt_api.c
··· 34 34 #include <linux/fs.h> 35 35 #include <linux/proc_fs.h> 36 36 #include <linux/compat.h> 37 + #include <linux/smp_lock.h> 37 38 #include <asm/atomic.h> 38 39 #include <asm/uaccess.h> 39 40 #include <linux/hw_random.h> ··· 301 300 */ 302 301 static int zcrypt_open(struct inode *inode, struct file *filp) 303 302 { 303 + lock_kernel(); 304 304 atomic_inc(&zcrypt_open_count); 305 + unlock_kernel(); 305 306 return 0; 306 307 } 307 308
+3
drivers/sbus/char/bpp.c
··· 19 19 #include <linux/timer.h> 20 20 #include <linux/ioport.h> 21 21 #include <linux/major.h> 22 + #include <linux/smp_lock.h> 22 23 23 24 #include <asm/uaccess.h> 24 25 #include <asm/io.h> ··· 430 429 unsigned minor = iminor(inode); 431 430 int ret; 432 431 432 + lock_kernel(); 433 433 spin_lock(&bpp_open_lock); 434 434 ret = 0; 435 435 if (minor >= BPP_NO) { ··· 446 444 } 447 445 } 448 446 spin_unlock(&bpp_open_lock); 447 + unlock_kernel(); 449 448 450 449 return ret; 451 450 }
+4
drivers/sbus/char/cpwatchdog.c
··· 279 279 280 280 static int wd_open(struct inode *inode, struct file *f) 281 281 { 282 + lock_kernel(); 282 283 switch(iminor(inode)) 283 284 { 284 285 case WD0_MINOR: ··· 292 291 f->private_data = &wd_dev.watchdog[WD2_ID]; 293 292 break; 294 293 default: 294 + unlock_kernel(); 295 295 return(-ENODEV); 296 296 } 297 297 ··· 306 304 (void *)wd_dev.regs)) { 307 305 printk("%s: Cannot register IRQ %d\n", 308 306 WD_OBPNAME, wd_dev.irq); 307 + unlock_kernel(); 309 308 return(-EBUSY); 310 309 } 311 310 wd_dev.initialized = 1; 312 311 } 313 312 313 + unlock_kernel(); 314 314 return(nonseekable_open(inode, f)); 315 315 } 316 316
+1
drivers/sbus/char/display7seg.c
··· 94 94 { 95 95 if (D7S_MINOR != iminor(inode)) 96 96 return -ENODEV; 97 + cycle_kernel_lock(); 97 98 atomic_inc(&d7s_users); 98 99 return 0; 99 100 }
+2
drivers/sbus/char/envctrl.c
··· 27 27 #include <linux/miscdevice.h> 28 28 #include <linux/kmod.h> 29 29 #include <linux/reboot.h> 30 + #include <linux/smp_lock.h> 30 31 31 32 #include <asm/ebus.h> 32 33 #include <asm/uaccess.h> ··· 695 694 static int 696 695 envctrl_open(struct inode *inode, struct file *file) 697 696 { 697 + cycle_kernel_lock(); 698 698 file->private_data = NULL; 699 699 return 0; 700 700 }
+5 -1
drivers/sbus/char/flash.c
··· 127 127 static int 128 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 133 return -EBUSY; 134 + } 132 135 136 + unlock_kernel(); 133 137 return 0; 134 138 } 135 139
+10 -3
drivers/sbus/char/jsflash.c
··· 27 27 */ 28 28 29 29 #include <linux/module.h> 30 + #include <linux/smp_lock.h> 30 31 #include <linux/types.h> 31 32 #include <linux/errno.h> 32 33 #include <linux/miscdevice.h> ··· 418 417 419 418 static int jsf_open(struct inode * inode, struct file * filp) 420 419 { 421 - 422 - if (jsf0.base == 0) return -ENXIO; 423 - if (test_and_set_bit(0, (void *)&jsf0.busy) != 0) 420 + lock_kernel(); 421 + if (jsf0.base == 0) { 422 + unlock_kernel(); 423 + return -ENXIO; 424 + } 425 + if (test_and_set_bit(0, (void *)&jsf0.busy) != 0) { 426 + unlock_kernel(); 424 427 return -EBUSY; 428 + } 425 429 430 + unlock_kernel(); 426 431 return 0; /* XXX What security? */ 427 432 } 428 433
+3
drivers/sbus/char/openprom.c
··· 33 33 #include <linux/kernel.h> 34 34 #include <linux/errno.h> 35 35 #include <linux/slab.h> 36 + #include <linux/smp_lock.h> 36 37 #include <linux/string.h> 37 38 #include <linux/miscdevice.h> 38 39 #include <linux/init.h> ··· 690 689 if (!data) 691 690 return -ENOMEM; 692 691 692 + lock_kernel(); 693 693 data->current_node = of_find_node_by_path("/"); 694 694 data->lastnode = data->current_node; 695 695 file->private_data = (void *) data; 696 + unlock_kernel(); 696 697 697 698 return 0; 698 699 }
+2
drivers/sbus/char/riowatchdog.c
··· 11 11 #include <linux/errno.h> 12 12 #include <linux/init.h> 13 13 #include <linux/miscdevice.h> 14 + #include <linux/smp_lock.h> 14 15 15 16 #include <asm/io.h> 16 17 #include <asm/ebus.h> ··· 117 116 118 117 static int riowd_open(struct inode *inode, struct file *filp) 119 118 { 119 + cycle_kernel_lock(); 120 120 nonseekable_open(inode, filp); 121 121 return 0; 122 122 }
+3
drivers/sbus/char/rtc.c
··· 12 12 */ 13 13 14 14 #include <linux/module.h> 15 + #include <linux/smp_lock.h> 15 16 #include <linux/types.h> 16 17 #include <linux/errno.h> 17 18 #include <linux/miscdevice.h> ··· 214 213 { 215 214 int ret; 216 215 216 + lock_kernel(); 217 217 spin_lock_irq(&mostek_lock); 218 218 if (rtc_busy) { 219 219 ret = -EBUSY; ··· 223 221 ret = 0; 224 222 } 225 223 spin_unlock_irq(&mostek_lock); 224 + unlock_kernel(); 226 225 227 226 return ret; 228 227 }
+3
drivers/sbus/char/uctrl.c
··· 9 9 #include <linux/delay.h> 10 10 #include <linux/interrupt.h> 11 11 #include <linux/slab.h> 12 + #include <linux/smp_lock.h> 12 13 #include <linux/ioport.h> 13 14 #include <linux/init.h> 14 15 #include <linux/miscdevice.h> ··· 212 211 static int 213 212 uctrl_open(struct inode *inode, struct file *file) 214 213 { 214 + lock_kernel(); 215 215 uctrl_get_event_status(); 216 216 uctrl_get_external_status(); 217 + unlock_kernel(); 217 218 return 0; 218 219 } 219 220
+5
drivers/sbus/char/vfc_dev.c
··· 24 24 #include <linux/spinlock.h> 25 25 #include <linux/mutex.h> 26 26 #include <linux/mm.h> 27 + #include <linux/smp_lock.h> 27 28 28 29 #include <asm/openprom.h> 29 30 #include <asm/oplib.h> ··· 179 178 { 180 179 struct vfc_dev *dev; 181 180 181 + lock_kernel(); 182 182 spin_lock(&vfc_dev_lock); 183 183 dev = vfc_get_dev_ptr(iminor(inode)); 184 184 if (dev == NULL) { 185 185 spin_unlock(&vfc_dev_lock); 186 + unlock_kernel(); 186 187 return -ENODEV; 187 188 } 188 189 if (dev->busy) { 189 190 spin_unlock(&vfc_dev_lock); 191 + unlock_kernel(); 190 192 return -EBUSY; 191 193 } 192 194 ··· 206 202 vfc_captstat_reset(dev); 207 203 208 204 vfc_unlock_device(dev); 205 + unlock_kernel(); 209 206 return 0; 210 207 } 211 208
+3
drivers/scsi/3w-9xxx.c
··· 84 84 #include <linux/pci.h> 85 85 #include <linux/time.h> 86 86 #include <linux/mutex.h> 87 + #include <linux/smp_lock.h> 87 88 #include <asm/io.h> 88 89 #include <asm/irq.h> 89 90 #include <asm/uaccess.h> ··· 863 862 } /* End twa_chrdev_ioctl() */ 864 863 865 864 /* This function handles open for the character device */ 865 + /* NOTE that this function will race with remove. */ 866 866 static int twa_chrdev_open(struct inode *inode, struct file *file) 867 867 { 868 868 unsigned int minor_number; 869 869 int retval = TW_IOCTL_ERROR_OS_ENODEV; 870 870 871 + cycle_kernel_lock(); 871 872 minor_number = iminor(inode); 872 873 if (minor_number >= twa_device_extension_count) 873 874 goto out;
+3
drivers/scsi/3w-xxxx.c
··· 198 198 199 199 #include <linux/module.h> 200 200 #include <linux/reboot.h> 201 + #include <linux/smp_lock.h> 201 202 #include <linux/spinlock.h> 202 203 #include <linux/interrupt.h> 203 204 #include <linux/moduleparam.h> ··· 1028 1027 } /* End tw_chrdev_ioctl() */ 1029 1028 1030 1029 /* This function handles open for the character device */ 1030 + /* NOTE that this function races with remove. */ 1031 1031 static int tw_chrdev_open(struct inode *inode, struct file *file) 1032 1032 { 1033 1033 unsigned int minor_number; 1034 1034 1035 + cycle_kernel_lock(); 1035 1036 dprintk(KERN_WARNING "3w-xxxx: tw_ioctl_open()\n"); 1036 1037 1037 1038 minor_number = iminor(inode);
+3
drivers/scsi/aacraid/linit.c
··· 38 38 #include <linux/moduleparam.h> 39 39 #include <linux/pci.h> 40 40 #include <linux/slab.h> 41 + #include <linux/smp_lock.h> 41 42 #include <linux/spinlock.h> 42 43 #include <linux/syscalls.h> 43 44 #include <linux/delay.h> ··· 668 667 unsigned minor_number = iminor(inode); 669 668 int err = -ENODEV; 670 669 670 + lock_kernel(); /* BKL pushdown: nothing else protects this list */ 671 671 list_for_each_entry(aac, &aac_devices, entry) { 672 672 if (aac->id == minor_number) { 673 673 file->private_data = aac; ··· 676 674 break; 677 675 } 678 676 } 677 + unlock_kernel(); 679 678 680 679 return err; 681 680 }
+4
drivers/scsi/ch.c
··· 22 22 #include <linux/chio.h> /* here are all the ioctls */ 23 23 #include <linux/mutex.h> 24 24 #include <linux/idr.h> 25 + #include <linux/smp_lock.h> 25 26 26 27 #include <scsi/scsi.h> 27 28 #include <scsi/scsi_cmnd.h> ··· 572 571 scsi_changer *ch; 573 572 int minor = iminor(inode); 574 573 574 + lock_kernel(); 575 575 spin_lock(&ch_index_lock); 576 576 ch = idr_find(&ch_index_idr, minor); 577 577 578 578 if (NULL == ch || scsi_device_get(ch->device)) { 579 579 spin_unlock(&ch_index_lock); 580 + unlock_kernel(); 580 581 return -ENXIO; 581 582 } 582 583 spin_unlock(&ch_index_lock); 583 584 584 585 file->private_data = ch; 586 + unlock_kernel(); 585 587 return 0; 586 588 } 587 589
+5
drivers/scsi/dpt_i2o.c
··· 49 49 #include <linux/kernel.h> /* for printk */ 50 50 #include <linux/sched.h> 51 51 #include <linux/reboot.h> 52 + #include <linux/smp_lock.h> 52 53 #include <linux/spinlock.h> 53 54 #include <linux/dma-mapping.h> 54 55 ··· 1728 1727 int minor; 1729 1728 adpt_hba* pHba; 1730 1729 1730 + lock_kernel(); 1731 1731 //TODO check for root access 1732 1732 // 1733 1733 minor = iminor(inode); 1734 1734 if (minor >= hba_count) { 1735 + unlock_kernel(); 1735 1736 return -ENXIO; 1736 1737 } 1737 1738 mutex_lock(&adpt_configuration_lock); ··· 1744 1741 } 1745 1742 if (pHba == NULL) { 1746 1743 mutex_unlock(&adpt_configuration_lock); 1744 + unlock_kernel(); 1747 1745 return -ENXIO; 1748 1746 } 1749 1747 ··· 1755 1751 1756 1752 pHba->in_use = 1; 1757 1753 mutex_unlock(&adpt_configuration_lock); 1754 + unlock_kernel(); 1758 1755 1759 1756 return 0; 1760 1757 }
+3
drivers/scsi/gdth.c
··· 120 120 #include <linux/timer.h> 121 121 #include <linux/dma-mapping.h> 122 122 #include <linux/list.h> 123 + #include <linux/smp_lock.h> 123 124 124 125 #ifdef GDTH_RTC 125 126 #include <linux/mc146818rtc.h> ··· 4020 4019 { 4021 4020 gdth_ha_str *ha; 4022 4021 4022 + lock_kernel(); 4023 4023 list_for_each_entry(ha, &gdth_instances, list) { 4024 4024 if (!ha->sdev) 4025 4025 ha->sdev = scsi_get_host_dev(ha->shost); 4026 4026 } 4027 + unlock_kernel(); 4027 4028 4028 4029 TRACE(("gdth_open()\n")); 4029 4030 return 0;
+3 -2
drivers/scsi/megaraid.c
··· 46 46 #include <linux/pci.h> 47 47 #include <linux/init.h> 48 48 #include <linux/dma-mapping.h> 49 + #include <linux/smp_lock.h> 49 50 #include <scsi/scsicam.h> 50 51 51 52 #include "scsi.h" ··· 3273 3272 * @filep - unused 3274 3273 * 3275 3274 * Routines for the character/ioctl interface to the driver. Find out if this 3276 - * is a valid open. If yes, increment the module use count so that it cannot 3277 - * be unloaded. 3275 + * is a valid open. 3278 3276 */ 3279 3277 static int 3280 3278 megadev_open (struct inode *inode, struct file *filep) 3281 3279 { 3280 + cycle_kernel_lock(); 3282 3281 /* 3283 3282 * Only allow superuser to access private ioctl interface 3284 3283 */
+2
drivers/scsi/megaraid/megaraid_mm.c
··· 15 15 * Common management module 16 16 */ 17 17 #include <linux/sched.h> 18 + #include <linux/smp_lock.h> 18 19 #include "megaraid_mm.h" 19 20 20 21 ··· 97 96 */ 98 97 if (!capable(CAP_SYS_ADMIN)) return (-EACCES); 99 98 99 + cycle_kernel_lock(); 100 100 return 0; 101 101 } 102 102
+2
drivers/scsi/megaraid/megaraid_sas.c
··· 33 33 #include <linux/spinlock.h> 34 34 #include <linux/interrupt.h> 35 35 #include <linux/delay.h> 36 + #include <linux/smp_lock.h> 36 37 #include <linux/uio.h> 37 38 #include <asm/uaccess.h> 38 39 #include <linux/fs.h> ··· 2864 2863 */ 2865 2864 static int megasas_mgmt_open(struct inode *inode, struct file *filep) 2866 2865 { 2866 + cycle_kernel_lock(); 2867 2867 /* 2868 2868 * Allow only those users with admin rights 2869 2869 */
+14 -1
drivers/scsi/osst.c
··· 50 50 #include <linux/moduleparam.h> 51 51 #include <linux/delay.h> 52 52 #include <linux/jiffies.h> 53 + #include <linux/smp_lock.h> 53 54 #include <asm/uaccess.h> 54 55 #include <asm/dma.h> 55 56 #include <asm/system.h> ··· 4360 4359 4361 4360 4362 4361 /* Open the device */ 4363 - static int os_scsi_tape_open(struct inode * inode, struct file * filp) 4362 + static int __os_scsi_tape_open(struct inode * inode, struct file * filp) 4364 4363 { 4365 4364 unsigned short flags; 4366 4365 int i, b_size, new_session = 0, retval = 0; ··· 4725 4724 4726 4725 return retval; 4727 4726 } 4727 + 4728 + /* BKL pushdown: spaghetti avoidance wrapper */ 4729 + static int os_scsi_tape_open(struct inode * inode, struct file * filp) 4730 + { 4731 + int ret; 4732 + 4733 + lock_kernel(); 4734 + ret = __os_scsi_tape_open(inode, filp); 4735 + unlock_kernel(); 4736 + return ret; 4737 + } 4738 + 4728 4739 4729 4740 4730 4741 /* Flush the tape buffer before close */
+2
drivers/scsi/scsi_tgt_if.c
··· 21 21 */ 22 22 #include <linux/miscdevice.h> 23 23 #include <linux/file.h> 24 + #include <linux/smp_lock.h> 24 25 #include <net/tcp.h> 25 26 #include <scsi/scsi.h> 26 27 #include <scsi/scsi_cmnd.h> ··· 322 321 { 323 322 tx_ring.tr_idx = rx_ring.tr_idx = 0; 324 323 324 + cycle_kernel_lock(); 325 325 return 0; 326 326 } 327 327
+13 -3
drivers/scsi/sg.c
··· 49 49 #include <linux/delay.h> 50 50 #include <linux/scatterlist.h> 51 51 #include <linux/blktrace_api.h> 52 + #include <linux/smp_lock.h> 52 53 53 54 #include "scsi.h" 54 55 #include <scsi/scsi_dbg.h> ··· 228 227 int res; 229 228 int retval; 230 229 230 + lock_kernel(); 231 231 nonseekable_open(inode, filp); 232 232 SCSI_LOG_TIMEOUT(3, printk("sg_open: dev=%d, flags=0x%x\n", dev, flags)); 233 233 sdp = sg_get_dev(dev); 234 - if ((!sdp) || (!sdp->device)) 234 + if ((!sdp) || (!sdp->device)) { 235 + unlock_kernel(); 235 236 return -ENXIO; 236 - if (sdp->detached) 237 + } 238 + if (sdp->detached) { 239 + unlock_kernel(); 237 240 return -ENODEV; 241 + } 238 242 239 243 /* This driver's module count bumped by fops_get in <linux/fs.h> */ 240 244 /* Prevent the device driver from vanishing while we sleep */ 241 245 retval = scsi_device_get(sdp->device); 242 - if (retval) 246 + if (retval) { 247 + unlock_kernel(); 243 248 return retval; 249 + } 244 250 245 251 if (!((flags & O_NONBLOCK) || 246 252 scsi_block_when_processing_errors(sdp->device))) { ··· 303 295 retval = -ENOMEM; 304 296 goto error_out; 305 297 } 298 + unlock_kernel(); 306 299 return 0; 307 300 308 301 error_out: 309 302 scsi_device_put(sdp->device); 303 + unlock_kernel(); 310 304 return retval; 311 305 } 312 306
+9 -2
drivers/scsi/st.c
··· 38 38 #include <linux/cdev.h> 39 39 #include <linux/delay.h> 40 40 #include <linux/mutex.h> 41 + #include <linux/smp_lock.h> 41 42 42 43 #include <asm/uaccess.h> 43 44 #include <asm/dma.h> ··· 1114 1113 } 1115 1114 1116 1115 1117 - /* Open the device. Needs to be called with BKL only because of incrementing the SCSI host 1116 + /* Open the device. Needs to take the BKL only because of incrementing the SCSI host 1118 1117 module count. */ 1119 1118 static int st_open(struct inode *inode, struct file *filp) 1120 1119 { ··· 1124 1123 int dev = TAPE_NR(inode); 1125 1124 char *name; 1126 1125 1126 + lock_kernel(); 1127 1127 /* 1128 1128 * We really want to do nonseekable_open(inode, filp); here, but some 1129 1129 * versions of tar incorrectly call lseek on tapes and bail out if that ··· 1132 1130 */ 1133 1131 filp->f_mode &= ~(FMODE_PREAD | FMODE_PWRITE); 1134 1132 1135 - if (!(STp = scsi_tape_get(dev))) 1133 + if (!(STp = scsi_tape_get(dev))) { 1134 + unlock_kernel(); 1136 1135 return -ENXIO; 1136 + } 1137 1137 1138 1138 write_lock(&st_dev_arr_lock); 1139 1139 filp->private_data = STp; ··· 1144 1140 if (STp->in_use) { 1145 1141 write_unlock(&st_dev_arr_lock); 1146 1142 scsi_tape_put(STp); 1143 + unlock_kernel(); 1147 1144 DEB( printk(ST_DEB_MSG "%s: Device already in use.\n", name); ) 1148 1145 return (-EBUSY); 1149 1146 } ··· 1193 1188 retval = (-EIO); 1194 1189 goto err_out; 1195 1190 } 1191 + unlock_kernel(); 1196 1192 return 0; 1197 1193 1198 1194 err_out: 1199 1195 normalize_buffer(STp->buffer); 1200 1196 STp->in_use = 0; 1201 1197 scsi_tape_put(STp); 1198 + unlock_kernel(); 1202 1199 return retval; 1203 1200 1204 1201 }
+3
drivers/spi/spidev.c
··· 30 30 #include <linux/errno.h> 31 31 #include <linux/mutex.h> 32 32 #include <linux/slab.h> 33 + #include <linux/smp_lock.h> 33 34 34 35 #include <linux/spi/spi.h> 35 36 #include <linux/spi/spidev.h> ··· 465 464 struct spidev_data *spidev; 466 465 int status = -ENXIO; 467 466 467 + lock_kernel(); 468 468 mutex_lock(&device_list_lock); 469 469 470 470 list_for_each_entry(spidev, &device_list, device_entry) { ··· 491 489 pr_debug("spidev: nothing for minor %d\n", iminor(inode)); 492 490 493 491 mutex_unlock(&device_list_lock); 492 + unlock_kernel(); 494 493 return status; 495 494 } 496 495
+3
drivers/telephony/phonedev.c
··· 23 23 #include <linux/errno.h> 24 24 #include <linux/phonedev.h> 25 25 #include <linux/init.h> 26 + #include <linux/smp_lock.h> 26 27 #include <asm/uaccess.h> 27 28 #include <asm/system.h> 28 29 ··· 54 53 if (minor >= PHONE_NUM_DEVICES) 55 54 return -ENODEV; 56 55 56 + lock_kernel(); 57 57 mutex_lock(&phone_lock); 58 58 p = phone_device[minor]; 59 59 if (p) ··· 81 79 fops_put(old_fops); 82 80 end: 83 81 mutex_unlock(&phone_lock); 82 + unlock_kernel(); 84 83 return err; 85 84 } 86 85
+12 -5
drivers/uio/uio.c
··· 297 297 struct uio_listener *listener; 298 298 int ret = 0; 299 299 300 + lock_kernel(); 300 301 idev = idr_find(&uio_idr, iminor(inode)); 301 - if (!idev) 302 - return -ENODEV; 302 + if (!idev) { 303 + ret = -ENODEV; 304 + goto out; 305 + } 303 306 304 - if (!try_module_get(idev->owner)) 305 - return -ENODEV; 307 + if (!try_module_get(idev->owner)) { 308 + ret = -ENODEV; 309 + goto out; 310 + } 306 311 307 312 listener = kmalloc(sizeof(*listener), GFP_KERNEL); 308 313 if (!listener) { ··· 324 319 if (ret) 325 320 goto err_infoopen; 326 321 } 327 - 322 + unlock_kernel(); 328 323 return 0; 329 324 330 325 err_infoopen: ··· 334 329 335 330 module_put(idev->owner); 336 331 332 + out: 333 + unlock_kernel(); 337 334 return ret; 338 335 } 339 336
+2
drivers/usb/core/devio.c
··· 565 565 struct dev_state *ps; 566 566 int ret; 567 567 568 + lock_kernel(); 568 569 /* Protect against simultaneous removal or release */ 569 570 mutex_lock(&usbfs_mutex); 570 571 ··· 612 611 if (ret) 613 612 kfree(ps); 614 613 mutex_unlock(&usbfs_mutex); 614 + unlock_kernel(); 615 615 return ret; 616 616 } 617 617
+3
drivers/usb/core/file.c
··· 18 18 #include <linux/module.h> 19 19 #include <linux/errno.h> 20 20 #include <linux/rwsem.h> 21 + #include <linux/smp_lock.h> 21 22 #include <linux/usb.h> 22 23 23 24 #include "usb.h" ··· 34 33 int err = -ENODEV; 35 34 const struct file_operations *old_fops, *new_fops = NULL; 36 35 36 + lock_kernel(); 37 37 down_read(&minor_rwsem); 38 38 c = usb_minors[minor]; 39 39 ··· 53 51 fops_put(old_fops); 54 52 done: 55 53 up_read(&minor_rwsem); 54 + unlock_kernel(); 56 55 return err; 57 56 } 58 57
+2 -1
drivers/usb/gadget/printer.c
··· 462 462 unsigned long flags; 463 463 int ret = -EBUSY; 464 464 465 + lock_kernel(); 465 466 dev = container_of(inode->i_cdev, struct printer_dev, printer_cdev); 466 467 467 468 spin_lock_irqsave(&dev->lock, flags); ··· 478 477 spin_unlock_irqrestore(&dev->lock, flags); 479 478 480 479 DBG(dev, "printer_open returned %x\n", ret); 481 - 480 + unlock_kernel(); 482 481 return ret; 483 482 } 484 483
+6
drivers/usb/mon/mon_bin.c
··· 15 15 #include <linux/poll.h> 16 16 #include <linux/compat.h> 17 17 #include <linux/mm.h> 18 + #include <linux/smp_lock.h> 18 19 19 20 #include <asm/uaccess.h> 20 21 ··· 528 527 size_t size; 529 528 int rc; 530 529 530 + lock_kernel(); 531 531 mutex_lock(&mon_lock); 532 532 if ((mbus = mon_bus_lookup(iminor(inode))) == NULL) { 533 533 mutex_unlock(&mon_lock); 534 + unlock_kernel(); 534 535 return -ENODEV; 535 536 } 536 537 if (mbus != &mon_bus0 && mbus->u_bus == NULL) { 537 538 printk(KERN_ERR TAG ": consistency error on open\n"); 538 539 mutex_unlock(&mon_lock); 540 + unlock_kernel(); 539 541 return -ENODEV; 540 542 } 541 543 ··· 572 568 573 569 file->private_data = rp; 574 570 mutex_unlock(&mon_lock); 571 + unlock_kernel(); 575 572 return 0; 576 573 577 574 err_allocbuff: ··· 581 576 kfree(rp); 582 577 err_alloc: 583 578 mutex_unlock(&mon_lock); 579 + unlock_kernel(); 584 580 return rc; 585 581 } 586 582
+11 -4
drivers/video/fbmem.c
··· 1326 1326 1327 1327 if (fbidx >= FB_MAX) 1328 1328 return -ENODEV; 1329 + lock_kernel(); 1329 1330 #ifdef CONFIG_KMOD 1330 1331 if (!(info = registered_fb[fbidx])) 1331 1332 try_to_load(fbidx); 1332 1333 #endif /* CONFIG_KMOD */ 1333 - if (!(info = registered_fb[fbidx])) 1334 - return -ENODEV; 1335 - if (!try_module_get(info->fbops->owner)) 1336 - return -ENODEV; 1334 + if (!(info = registered_fb[fbidx])) { 1335 + res = -ENODEV; 1336 + goto out; 1337 + } 1338 + if (!try_module_get(info->fbops->owner)) { 1339 + res = -ENODEV; 1340 + goto out; 1341 + } 1337 1342 file->private_data = info; 1338 1343 if (info->fbops->fb_open) { 1339 1344 res = info->fbops->fb_open(info,1); 1340 1345 if (res) 1341 1346 module_put(info->fbops->owner); 1342 1347 } 1348 + out: 1349 + unlock_kernel(); 1343 1350 return res; 1344 1351 } 1345 1352
+3 -4
fs/char_dev.c
··· 373 373 return -ENXIO; 374 374 new = container_of(kobj, struct cdev, kobj); 375 375 spin_lock(&cdev_lock); 376 + /* Check i_cdev again in case somebody beat us to it while 377 + we dropped the lock. */ 376 378 p = inode->i_cdev; 377 379 if (!p) { 378 380 inode->i_cdev = p = new; ··· 394 392 cdev_put(p); 395 393 return -ENXIO; 396 394 } 397 - if (filp->f_op->open) { 398 - lock_kernel(); 395 + if (filp->f_op->open) 399 396 ret = filp->f_op->open(inode,filp); 400 - unlock_kernel(); 401 - } 402 397 if (ret) 403 398 cdev_put(p); 404 399 return ret;
+1 -1
fs/cifs/cifsfs.c
··· 612 612 if (retval < 0) 613 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 618 struct file_system_type cifs_fs_type = {
+8 -1
fs/dlm/user.c
··· 15 15 #include <linux/poll.h> 16 16 #include <linux/signal.h> 17 17 #include <linux/spinlock.h> 18 + #include <linux/smp_lock.h> 18 19 #include <linux/dlm.h> 19 20 #include <linux/dlm_device.h> 20 21 ··· 619 618 struct dlm_user_proc *proc; 620 619 struct dlm_ls *ls; 621 620 621 + lock_kernel(); 622 622 ls = dlm_find_lockspace_device(iminor(inode)); 623 - if (!ls) 623 + if (!ls) { 624 + unlock_kernel(); 624 625 return -ENOENT; 626 + } 625 627 626 628 proc = kzalloc(sizeof(struct dlm_user_proc), GFP_KERNEL); 627 629 if (!proc) { 628 630 dlm_put_lockspace(ls); 631 + unlock_kernel(); 629 632 return -ENOMEM; 630 633 } 631 634 ··· 641 636 spin_lock_init(&proc->locks_spin); 642 637 init_waitqueue_head(&proc->wait); 643 638 file->private_data = proc; 639 + unlock_kernel(); 644 640 645 641 return 0; 646 642 } ··· 876 870 877 871 static int ctl_device_open(struct inode *inode, struct file *file) 878 872 { 873 + cycle_kernel_lock(); 879 874 file->private_data = NULL; 880 875 return 0; 881 876 }
+3
fs/ecryptfs/file.c
··· 30 30 #include <linux/security.h> 31 31 #include <linux/compat.h> 32 32 #include <linux/fs_stack.h> 33 + #include <linux/smp_lock.h> 33 34 #include "ecryptfs_kernel.h" 34 35 35 36 /** ··· 278 277 int rc = 0; 279 278 struct file *lower_file = NULL; 280 279 280 + lock_kernel(); 281 281 lower_file = ecryptfs_file_to_lower(file); 282 282 if (lower_file->f_op && lower_file->f_op->fasync) 283 283 rc = lower_file->f_op->fasync(fd, lower_file, flag); 284 + unlock_kernel(); 284 285 return rc; 285 286 } 286 287
+1 -1
fs/fat/cache.c
··· 61 61 62 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 67 static inline void fat_cache_free(struct fat_cache *cache)
+2 -2
fs/fat/dir.c
··· 472 472 loff_t cpos; 473 473 int ret = 0; 474 474 475 - lock_kernel(); 475 + lock_super(sb); 476 476 477 477 cpos = filp->f_pos; 478 478 /* Fake . and .. for the root directory. */ ··· 654 654 if (unicode) 655 655 __putname(unicode); 656 656 out: 657 - unlock_kernel(); 657 + unlock_super(sb); 658 658 return ret; 659 659 } 660 660
-6
fs/fat/file.c
··· 11 11 #include <linux/mount.h> 12 12 #include <linux/time.h> 13 13 #include <linux/msdos_fs.h> 14 - #include <linux/smp_lock.h> 15 14 #include <linux/buffer_head.h> 16 15 #include <linux/writeback.h> 17 16 #include <linux/backing-dev.h> ··· 241 242 242 243 nr_clusters = (inode->i_size + (cluster_size - 1)) >> sbi->cluster_bits; 243 244 244 - lock_kernel(); 245 245 fat_free(inode, nr_clusters); 246 - unlock_kernel(); 247 246 fat_flush_inodes(inode->i_sb, inode, NULL); 248 247 } 249 248 ··· 307 310 int error = 0; 308 311 unsigned int ia_valid; 309 312 310 - lock_kernel(); 311 - 312 313 /* 313 314 * Expand the file. Since inode_setattr() updates ->i_size 314 315 * before calling the ->truncate(), but FAT needs to fill the ··· 361 366 362 367 error = inode_setattr(inode, attr); 363 368 out: 364 - unlock_kernel(); 365 369 return error; 366 370 } 367 371 EXPORT_SYMBOL_GPL(fat_setattr);
+16 -10
fs/fat/inode.c
··· 440 440 441 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 446 spin_lock(&sbi->inode_hash_lock); 447 447 fat_cache_inval_inode(inode); 448 448 hlist_del_init(&MSDOS_I(inode)->i_fat_hash); 449 449 spin_unlock(&sbi->inode_hash_lock); 450 - unlock_kernel(); 451 450 } 452 451 453 452 static void fat_write_super(struct super_block *sb) ··· 484 485 static struct inode *fat_alloc_inode(struct super_block *sb) 485 486 { 486 487 struct msdos_inode_info *ei; 487 - ei = kmem_cache_alloc(fat_inode_cachep, GFP_KERNEL); 488 + ei = kmem_cache_alloc(fat_inode_cachep, GFP_NOFS); 488 489 if (!ei) 489 490 return NULL; 490 491 return &ei->vfs_inode; ··· 566 567 if (inode->i_ino == MSDOS_ROOT_INO || !i_pos) 567 568 return 0; 568 569 569 - lock_kernel(); 570 + lock_super(sb); 570 571 bh = sb_bread(sb, i_pos >> sbi->dir_per_block_bits); 571 572 if (!bh) { 572 573 printk(KERN_ERR "FAT: unable to read inode block " ··· 578 579 if (i_pos != MSDOS_I(inode)->i_pos) { 579 580 spin_unlock(&sbi->inode_hash_lock); 580 581 brelse(bh); 581 - unlock_kernel(); 582 + unlock_super(sb); 582 583 goto retry; 583 584 } 584 585 ··· 605 606 err = sync_dirty_buffer(bh); 606 607 brelse(bh); 607 608 out: 608 - unlock_kernel(); 609 + unlock_super(sb); 609 610 return err; 610 611 } 611 612 ··· 735 736 736 737 static struct dentry *fat_get_parent(struct dentry *child) 737 738 { 739 + struct super_block *sb = child->d_sb; 738 740 struct buffer_head *bh; 739 741 struct msdos_dir_entry *de; 740 742 loff_t i_pos; ··· 743 743 struct inode *inode; 744 744 int err; 745 745 746 - lock_kernel(); 746 + lock_super(sb); 747 747 748 748 err = fat_get_dotdot_entry(child->d_inode, &bh, &de, &i_pos); 749 749 if (err) { 750 750 parent = ERR_PTR(err); 751 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 754 brelse(bh); 755 755 if (IS_ERR(inode)) { 756 756 parent = ERR_CAST(inode); ··· 762 762 parent = ERR_PTR(-ENOMEM); 763 763 } 764 764 out: 765 - unlock_kernel(); 765 + unlock_super(sb); 766 766 767 767 return parent; 768 768 } ··· 1172 1172 long error; 1173 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 1181 sbi = kzalloc(sizeof(struct msdos_sb_info), GFP_KERNEL); 1176 1182 if (!sbi) 1177 1183 return -ENOMEM;
-3
fs/fcntl.c
··· 12 12 #include <linux/fdtable.h> 13 13 #include <linux/capability.h> 14 14 #include <linux/dnotify.h> 15 - #include <linux/smp_lock.h> 16 15 #include <linux/slab.h> 17 16 #include <linux/module.h> 18 17 #include <linux/security.h> ··· 226 227 if (error) 227 228 return error; 228 229 229 - lock_kernel(); 230 230 if ((arg ^ filp->f_flags) & FASYNC) { 231 231 if (filp->f_op && filp->f_op->fasync) { 232 232 error = filp->f_op->fasync(fd, filp, (arg & FASYNC) != 0); ··· 236 238 237 239 filp->f_flags = (arg & SETFL_MASK) | (filp->f_flags & ~SETFL_MASK); 238 240 out: 239 - unlock_kernel(); 240 241 return error; 241 242 } 242 243
+2 -2
fs/gfs2/ops_file.c
··· 62 62 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, 63 63 &i_gh); 64 64 if (!error) { 65 - error = remote_llseek(file, offset, origin); 65 + error = generic_file_llseek_unlocked(file, offset, origin); 66 66 gfs2_glock_dq_uninit(&i_gh); 67 67 } 68 68 } else 69 - error = remote_llseek(file, offset, origin); 69 + error = generic_file_llseek_unlocked(file, offset, origin); 70 70 71 71 return error; 72 72 }
+19 -16
fs/msdos/namei.c
··· 214 214 215 215 dentry->d_op = &msdos_dentry_operations; 216 216 217 - lock_kernel(); 217 + lock_super(sb); 218 218 res = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo); 219 219 if (res == -ENOENT) 220 220 goto add; ··· 232 232 if (dentry) 233 233 dentry->d_op = &msdos_dentry_operations; 234 234 out: 235 - unlock_kernel(); 235 + unlock_super(sb); 236 236 if (!res) 237 237 return dentry; 238 238 return ERR_PTR(res); ··· 286 286 unsigned char msdos_name[MSDOS_NAME]; 287 287 int err, is_hid; 288 288 289 - lock_kernel(); 289 + lock_super(sb); 290 290 291 291 err = msdos_format_name(dentry->d_name.name, dentry->d_name.len, 292 292 msdos_name, &MSDOS_SB(sb)->options); ··· 315 315 316 316 d_instantiate(dentry, inode); 317 317 out: 318 - unlock_kernel(); 318 + unlock_super(sb); 319 319 if (!err) 320 320 err = fat_flush_inodes(sb, dir, inode); 321 321 return err; ··· 324 324 /***** Remove a directory */ 325 325 static int msdos_rmdir(struct inode *dir, struct dentry *dentry) 326 326 { 327 + struct super_block *sb = dir->i_sb; 327 328 struct inode *inode = dentry->d_inode; 328 329 struct fat_slot_info sinfo; 329 330 int err; 330 331 331 - lock_kernel(); 332 + lock_super(sb); 332 333 /* 333 334 * Check whether the directory is not in use, then check 334 335 * whether it is empty. ··· 350 349 inode->i_ctime = CURRENT_TIME_SEC; 351 350 fat_detach(inode); 352 351 out: 353 - unlock_kernel(); 352 + unlock_super(sb); 354 353 if (!err) 355 - err = fat_flush_inodes(inode->i_sb, dir, inode); 354 + err = fat_flush_inodes(sb, dir, inode); 356 355 357 356 return err; 358 357 } ··· 367 366 struct timespec ts; 368 367 int err, is_hid, cluster; 369 368 370 - lock_kernel(); 369 + lock_super(sb); 371 370 372 371 err = msdos_format_name(dentry->d_name.name, dentry->d_name.len, 373 372 msdos_name, &MSDOS_SB(sb)->options); ··· 405 404 406 405 d_instantiate(dentry, inode); 407 406 408 - unlock_kernel(); 407 + unlock_super(sb); 409 408 fat_flush_inodes(sb, dir, inode); 410 409 return 0; 411 410 412 411 out_free: 413 412 fat_free_clusters(dir, cluster); 414 413 out: 415 - unlock_kernel(); 414 + unlock_super(sb); 416 415 return err; 417 416 } 418 417 ··· 420 419 static int msdos_unlink(struct inode *dir, struct dentry *dentry) 421 420 { 422 421 struct inode *inode = dentry->d_inode; 422 + struct super_block *sb= inode->i_sb; 423 423 struct fat_slot_info sinfo; 424 424 int err; 425 425 426 - lock_kernel(); 426 + lock_super(sb); 427 427 err = msdos_find(dir, dentry->d_name.name, dentry->d_name.len, &sinfo); 428 428 if (err) 429 429 goto out; ··· 436 434 inode->i_ctime = CURRENT_TIME_SEC; 437 435 fat_detach(inode); 438 436 out: 439 - unlock_kernel(); 437 + unlock_super(sb); 440 438 if (!err) 441 - err = fat_flush_inodes(inode->i_sb, dir, inode); 439 + err = fat_flush_inodes(sb, dir, inode); 442 440 443 441 return err; 444 442 } ··· 620 618 static int msdos_rename(struct inode *old_dir, struct dentry *old_dentry, 621 619 struct inode *new_dir, struct dentry *new_dentry) 622 620 { 621 + struct super_block *sb = old_dir->i_sb; 623 622 unsigned char old_msdos_name[MSDOS_NAME], new_msdos_name[MSDOS_NAME]; 624 623 int err, is_hid; 625 624 626 - lock_kernel(); 625 + lock_super(sb); 627 626 628 627 err = msdos_format_name(old_dentry->d_name.name, 629 628 old_dentry->d_name.len, old_msdos_name, ··· 643 640 err = do_msdos_rename(old_dir, old_msdos_name, old_dentry, 644 641 new_dir, new_msdos_name, new_dentry, is_hid); 645 642 out: 646 - unlock_kernel(); 643 + unlock_super(sb); 647 644 if (!err) 648 - err = fat_flush_inodes(old_dir->i_sb, old_dir, new_dir); 645 + err = fat_flush_inodes(sb, old_dir, new_dir); 649 646 return err; 650 647 } 651 648
+11 -1
fs/ncpfs/file.c
··· 18 18 #include <linux/slab.h> 19 19 #include <linux/vmalloc.h> 20 20 #include <linux/sched.h> 21 + #include <linux/smp_lock.h> 21 22 22 23 #include <linux/ncp_fs.h> 23 24 #include "ncplib_kernel.h" ··· 282 281 return 0; 283 282 } 284 283 284 + static loff_t ncp_remote_llseek(struct file *file, loff_t offset, int origin) 285 + { 286 + loff_t ret; 287 + lock_kernel(); 288 + ret = generic_file_llseek_unlocked(file, offset, origin); 289 + unlock_kernel(); 290 + return ret; 291 + } 292 + 285 293 const struct file_operations ncp_file_operations = 286 294 { 287 - .llseek = remote_llseek, 295 + .llseek = ncp_remote_llseek, 288 296 .read = ncp_file_read, 289 297 .write = ncp_file_write, 290 298 .ioctl = ncp_ioctl,
+5 -1
fs/nfs/file.c
··· 170 170 171 171 static loff_t nfs_file_llseek(struct file *filp, loff_t offset, int origin) 172 172 { 173 + loff_t loff; 173 174 /* origin == SEEK_END => we must revalidate the cached file length */ 174 175 if (origin == SEEK_END) { 175 176 struct inode *inode = filp->f_mapping->host; ··· 178 177 if (retval < 0) 179 178 return (loff_t)retval; 180 179 } 181 - return remote_llseek(filp, offset, origin); 180 + lock_kernel(); /* BKL needed? */ 181 + loff = generic_file_llseek_unlocked(filp, offset, origin); 182 + unlock_kernel(); 183 + return loff; 182 184 } 183 185 184 186 /*
+3
fs/ocfs2/stack_user.c
··· 21 21 #include <linux/fs.h> 22 22 #include <linux/miscdevice.h> 23 23 #include <linux/mutex.h> 24 + #include <linux/smp_lock.h> 24 25 #include <linux/reboot.h> 25 26 #include <asm/uaccess.h> 26 27 ··· 620 619 return -ENOMEM; 621 620 p->op_this_node = -1; 622 621 622 + lock_kernel(); 623 623 mutex_lock(&ocfs2_control_lock); 624 624 file->private_data = p; 625 625 list_add(&p->op_list, &ocfs2_control_private_list); 626 626 mutex_unlock(&ocfs2_control_lock); 627 + unlock_kernel(); 627 628 628 629 return 0; 629 630 }
+11 -27
fs/read_write.c
··· 31 31 32 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 37 loff_t retval; 37 38 struct inode *inode = file->f_mapping->host; 38 39 39 - mutex_lock(&inode->i_mutex); 40 40 switch (origin) { 41 41 case SEEK_END: 42 42 offset += inode->i_size; ··· 46 46 } 47 47 retval = -EINVAL; 48 48 if (offset>=0 && offset<=inode->i_sb->s_maxbytes) { 49 + /* Special lock needed here? */ 49 50 if (offset != file->f_pos) { 50 51 file->f_pos = offset; 51 52 file->f_version = 0; 52 53 } 53 54 retval = offset; 54 55 } 55 - mutex_unlock(&inode->i_mutex); 56 56 return retval; 57 57 } 58 + EXPORT_SYMBOL(generic_file_llseek_unlocked); 58 59 59 - EXPORT_SYMBOL(generic_file_llseek); 60 - 61 - loff_t remote_llseek(struct file *file, loff_t offset, int origin) 60 + loff_t generic_file_llseek(struct file *file, loff_t offset, int origin) 62 61 { 63 - loff_t retval; 64 - 65 - lock_kernel(); 66 - switch (origin) { 67 - case SEEK_END: 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; 62 + loff_t n; 63 + mutex_lock(&file->f_dentry->d_inode->i_mutex); 64 + n = generic_file_llseek_unlocked(file, offset, origin); 65 + mutex_unlock(&file->f_dentry->d_inode->i_mutex); 66 + return n; 83 67 } 84 - EXPORT_SYMBOL(remote_llseek); 68 + EXPORT_SYMBOL(generic_file_llseek); 85 69 86 70 loff_t no_llseek(struct file *file, loff_t offset, int origin) 87 71 {
+10 -1
fs/smbfs/file.c
··· 422 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 434 const struct file_operations smb_file_operations = 426 435 { 427 - .llseek = remote_llseek, 436 + .llseek = smb_remote_llseek, 428 437 .read = do_sync_read, 429 438 .aio_read = smb_file_aio_read, 430 439 .write = do_sync_write,
+19 -16
fs/vfat/namei.c
··· 645 645 if (len == 0) 646 646 return -ENOENT; 647 647 648 - slots = kmalloc(sizeof(*slots) * MSDOS_SLOTS, GFP_KERNEL); 648 + slots = kmalloc(sizeof(*slots) * MSDOS_SLOTS, GFP_NOFS); 649 649 if (slots == NULL) 650 650 return -ENOMEM; 651 651 ··· 687 687 struct dentry *alias; 688 688 int err, table; 689 689 690 - lock_kernel(); 690 + lock_super(sb); 691 691 table = (MSDOS_SB(sb)->options.name_check == 's') ? 2 : 0; 692 692 dentry->d_op = &vfat_dentry_ops[table]; 693 693 ··· 699 699 inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos); 700 700 brelse(sinfo.bh); 701 701 if (IS_ERR(inode)) { 702 - unlock_kernel(); 702 + unlock_super(sb); 703 703 return ERR_CAST(inode); 704 704 } 705 705 alias = d_find_alias(inode); ··· 708 708 dput(alias); 709 709 else { 710 710 iput(inode); 711 - unlock_kernel(); 711 + unlock_super(sb); 712 712 return alias; 713 713 } 714 714 715 715 } 716 716 error: 717 - unlock_kernel(); 717 + unlock_super(sb); 718 718 dentry->d_op = &vfat_dentry_ops[table]; 719 719 dentry->d_time = dentry->d_parent->d_inode->i_version; 720 720 dentry = d_splice_alias(inode, dentry); ··· 734 734 struct timespec ts; 735 735 int err; 736 736 737 - lock_kernel(); 737 + lock_super(sb); 738 738 739 739 ts = CURRENT_TIME_SEC; 740 740 err = vfat_add_entry(dir, &dentry->d_name, 0, 0, &ts, &sinfo); ··· 755 755 dentry->d_time = dentry->d_parent->d_inode->i_version; 756 756 d_instantiate(dentry, inode); 757 757 out: 758 - unlock_kernel(); 758 + unlock_super(sb); 759 759 return err; 760 760 } 761 761 762 762 static int vfat_rmdir(struct inode *dir, struct dentry *dentry) 763 763 { 764 764 struct inode *inode = dentry->d_inode; 765 + struct super_block *sb = dir->i_sb; 765 766 struct fat_slot_info sinfo; 766 767 int err; 767 768 768 - lock_kernel(); 769 + lock_super(sb); 769 770 770 771 err = fat_dir_empty(inode); 771 772 if (err) ··· 784 783 inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; 785 784 fat_detach(inode); 786 785 out: 787 - unlock_kernel(); 786 + unlock_super(sb); 788 787 789 788 return err; 790 789 } ··· 792 791 static int vfat_unlink(struct inode *dir, struct dentry *dentry) 793 792 { 794 793 struct inode *inode = dentry->d_inode; 794 + struct super_block *sb = dir->i_sb; 795 795 struct fat_slot_info sinfo; 796 796 int err; 797 797 798 - lock_kernel(); 798 + lock_super(sb); 799 799 800 800 err = vfat_find(dir, &dentry->d_name, &sinfo); 801 801 if (err) ··· 809 807 inode->i_mtime = inode->i_atime = CURRENT_TIME_SEC; 810 808 fat_detach(inode); 811 809 out: 812 - unlock_kernel(); 810 + unlock_super(sb); 813 811 814 812 return err; 815 813 } ··· 822 820 struct timespec ts; 823 821 int err, cluster; 824 822 825 - lock_kernel(); 823 + lock_super(sb); 826 824 827 825 ts = CURRENT_TIME_SEC; 828 826 cluster = fat_alloc_new_dir(dir, &ts); ··· 851 849 dentry->d_time = dentry->d_parent->d_inode->i_version; 852 850 d_instantiate(dentry, inode); 853 851 854 - unlock_kernel(); 852 + unlock_super(sb); 855 853 return 0; 856 854 857 855 out_free: 858 856 fat_free_clusters(dir, cluster); 859 857 out: 860 - unlock_kernel(); 858 + unlock_super(sb); 861 859 return err; 862 860 } 863 861 ··· 871 869 struct timespec ts; 872 870 loff_t dotdot_i_pos, new_i_pos; 873 871 int err, is_dir, update_dotdot, corrupt = 0; 872 + struct super_block *sb = old_dir->i_sb; 874 873 875 874 old_sinfo.bh = sinfo.bh = dotdot_bh = NULL; 876 875 old_inode = old_dentry->d_inode; 877 876 new_inode = new_dentry->d_inode; 878 - lock_kernel(); 877 + lock_super(sb); 879 878 err = vfat_find(old_dir, &old_dentry->d_name, &old_sinfo); 880 879 if (err) 881 880 goto out; ··· 954 951 brelse(sinfo.bh); 955 952 brelse(dotdot_bh); 956 953 brelse(old_sinfo.bh); 957 - unlock_kernel(); 954 + unlock_super(sb); 958 955 959 956 return err; 960 957
+2 -1
include/linux/fs.h
··· 1870 1870 file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping); 1871 1871 extern loff_t no_llseek(struct file *file, loff_t offset, int origin); 1872 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 1875 extern int generic_file_open(struct inode * inode, struct file * filp); 1875 1876 extern int nonseekable_open(struct inode * inode, struct file * filp); 1876 1877
+13
include/linux/smp_lock.h
··· 27 27 extern void __lockfunc lock_kernel(void) __acquires(kernel_lock); 28 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 42 #else 31 43 32 44 #define lock_kernel() do { } while(0) 33 45 #define unlock_kernel() do { } while(0) 34 46 #define release_kernel_lock(task) do { } while(0) 47 + #define cycle_kernel_lock() do { } while(0) 35 48 #define reacquire_kernel_lock(task) 0 36 49 #define kernel_locked() 1 37 50
+6 -1
kernel/pm_qos_params.c
··· 29 29 30 30 #include <linux/pm_qos_params.h> 31 31 #include <linux/sched.h> 32 + #include <linux/smp_lock.h> 32 33 #include <linux/spinlock.h> 33 34 #include <linux/slab.h> 34 35 #include <linux/time.h> ··· 359 358 int ret; 360 359 long pm_qos_class; 361 360 361 + lock_kernel(); 362 362 pm_qos_class = find_pm_qos_object_by_minor(iminor(inode)); 363 363 if (pm_qos_class >= 0) { 364 364 filp->private_data = (void *)pm_qos_class; 365 365 sprintf(name, "process_%d", current->pid); 366 366 ret = pm_qos_add_requirement(pm_qos_class, name, 367 367 PM_QOS_DEFAULT_VALUE); 368 - if (ret >= 0) 368 + if (ret >= 0) { 369 + unlock_kernel(); 369 370 return 0; 371 + } 370 372 } 373 + unlock_kernel(); 371 374 372 375 return -EPERM; 373 376 }
+1
net/irda/irnet/irnet.h
··· 241 241 #include <linux/module.h> 242 242 243 243 #include <linux/kernel.h> 244 + #include <linux/smp_lock.h> 244 245 #include <linux/skbuff.h> 245 246 #include <linux/tty.h> 246 247 #include <linux/proc_fs.h>
+3
net/irda/irnet/irnet_ppp.c
··· 479 479 ap = kzalloc(sizeof(*ap), GFP_KERNEL); 480 480 DABORT(ap == NULL, -ENOMEM, FS_ERROR, "Can't allocate struct irnet...\n"); 481 481 482 + lock_kernel(); 482 483 /* initialize the irnet structure */ 483 484 ap->file = file; 484 485 ··· 501 500 { 502 501 DERROR(FS_ERROR, "Can't setup IrDA link...\n"); 503 502 kfree(ap); 503 + unlock_kernel(); 504 504 return err; 505 505 } 506 506 ··· 512 510 file->private_data = ap; 513 511 514 512 DEXIT(FS_TRACE, " - ap=0x%p\n", ap); 513 + unlock_kernel(); 515 514 return 0; 516 515 } 517 516
+6 -2
sound/core/pcm_native.c
··· 22 22 #include <linux/mm.h> 23 23 #include <linux/file.h> 24 24 #include <linux/slab.h> 25 + #include <linux/smp_lock.h> 25 26 #include <linux/time.h> 26 27 #include <linux/pm_qos_params.h> 27 28 #include <linux/uio.h> ··· 3250 3249 struct snd_pcm_file * pcm_file; 3251 3250 struct snd_pcm_substream *substream; 3252 3251 struct snd_pcm_runtime *runtime; 3253 - int err; 3252 + int err = -ENXIO; 3254 3253 3254 + lock_kernel(); 3255 3255 pcm_file = file->private_data; 3256 3256 substream = pcm_file->substream; 3257 - snd_assert(substream != NULL, return -ENXIO); 3257 + snd_assert(substream != NULL, goto out); 3258 3258 runtime = substream->runtime; 3259 3259 3260 3260 err = fasync_helper(fd, file, on, &runtime->fasync); 3261 + out: 3262 + unlock_kernel(); 3261 3263 if (err < 0) 3262 3264 return err; 3263 3265 return 0;
+14 -1
sound/core/sound.c
··· 21 21 22 22 #include <linux/init.h> 23 23 #include <linux/slab.h> 24 + #include <linux/smp_lock.h> 24 25 #include <linux/time.h> 25 26 #include <linux/device.h> 26 27 #include <linux/moduleparam.h> ··· 122 121 123 122 EXPORT_SYMBOL(snd_lookup_minor_data); 124 123 125 - static int snd_open(struct inode *inode, struct file *file) 124 + static int __snd_open(struct inode *inode, struct file *file) 126 125 { 127 126 unsigned int minor = iminor(inode); 128 127 struct snd_minor *mptr = NULL; ··· 162 161 } 163 162 fops_put(old_fops); 164 163 return err; 164 + } 165 + 166 + 167 + /* BKL pushdown: nasty #ifdef avoidance wrapper */ 168 + static int snd_open(struct inode *inode, struct file *file) 169 + { 170 + int ret; 171 + 172 + lock_kernel(); 173 + ret = __snd_open(inode, file); 174 + unlock_kernel(); 175 + return ret; 165 176 } 166 177 167 178 static const struct file_operations snd_fops =
+5
sound/sound_core.c
··· 37 37 #include <linux/module.h> 38 38 #include <linux/init.h> 39 39 #include <linux/slab.h> 40 + #include <linux/smp_lock.h> 40 41 #include <linux/types.h> 41 42 #include <linux/kernel.h> 42 43 #include <linux/fs.h> ··· 465 464 struct sound_unit *s; 466 465 const struct file_operations *new_fops = NULL; 467 466 467 + lock_kernel (); 468 + 468 469 chain=unit&0x0F; 469 470 if(chain==4 || chain==5) /* dsp/audio/dsp16 */ 470 471 { ··· 514 511 file->f_op = fops_get(old_fops); 515 512 } 516 513 fops_put(old_fops); 514 + unlock_kernel(); 517 515 return err; 518 516 } 519 517 spin_unlock(&sound_loader_lock); 518 + unlock_kernel(); 520 519 return -ENODEV; 521 520 } 522 521