aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-07-11 13:10:50 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-07-11 13:10:50 -0400
commita74aa9676c0256eac05efb2c8e3127e0835e66e5 (patch)
tree00aaaad738bb8f32692c82671a21ea76dbea4d7a
parent1dc85ac274d1e42f7c24d50b186d748a61f02188 (diff)
parent87ed1405ef09d29a14df43295f7b6a93b63bfe6e (diff)
Merge tag 'char-misc-4.18-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc
Pull char/misc fixes from Greg KH: "Here are a few char/misc driver fixes for 4.18-rc5. The "largest" stuff here is fixes for the UIO changes in 4.18-rc1 that caused breakages for some people. Thanks to Xiubo Li for fixing them quickly. Other than that, minor fixes for thunderbolt, vmw_balloon, nvmem, mei, ibmasm, and mei drivers. There's also a MAINTAINERS update where Rafael is offering to help out with reviewing driver core patches. All of these have been in linux-next with no reported issues" * tag 'char-misc-4.18-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: nvmem: Don't let a NULL cell_id for nvmem_cell_get() crash us thunderbolt: Notify userspace when boot_acl is changed uio: fix crash after the device is unregistered uio: change to use the mutex lock instead of the spin lock uio: use request_threaded_irq instead fpga: altera-cvp: Fix an error handling path in 'altera_cvp_probe()' ibmasm: don't write out of bounds in read handler MAINTAINERS: Add myself as driver core changes reviewer mei: discard messages from not connected client during power down. vmw_balloon: fix inflation with batching
-rw-r--r--MAINTAINERS1
-rw-r--r--drivers/fpga/altera-cvp.c6
-rw-r--r--drivers/misc/ibmasm/ibmasmfs.c27
-rw-r--r--drivers/misc/mei/interrupt.c5
-rw-r--r--drivers/misc/vmw_balloon.c4
-rw-r--r--drivers/nvmem/core.c4
-rw-r--r--drivers/thunderbolt/domain.c4
-rw-r--r--drivers/uio/uio.c139
-rw-r--r--include/linux/uio_driver.h2
9 files changed, 126 insertions, 66 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 13fef810e3fa..192d7f73fd01 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4460,6 +4460,7 @@ F: Documentation/blockdev/drbd/
4460 4460
4461DRIVER CORE, KOBJECTS, DEBUGFS AND SYSFS 4461DRIVER CORE, KOBJECTS, DEBUGFS AND SYSFS
4462M: Greg Kroah-Hartman <gregkh@linuxfoundation.org> 4462M: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
4463R: "Rafael J. Wysocki" <rafael@kernel.org>
4463T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git 4464T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git
4464S: Supported 4465S: Supported
4465F: Documentation/kobject.txt 4466F: Documentation/kobject.txt
diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c
index dd4edd8f22ce..7fa793672a7a 100644
--- a/drivers/fpga/altera-cvp.c
+++ b/drivers/fpga/altera-cvp.c
@@ -455,8 +455,10 @@ static int altera_cvp_probe(struct pci_dev *pdev,
455 455
456 mgr = fpga_mgr_create(&pdev->dev, conf->mgr_name, 456 mgr = fpga_mgr_create(&pdev->dev, conf->mgr_name,
457 &altera_cvp_ops, conf); 457 &altera_cvp_ops, conf);
458 if (!mgr) 458 if (!mgr) {
459 return -ENOMEM; 459 ret = -ENOMEM;
460 goto err_unmap;
461 }
460 462
461 pci_set_drvdata(pdev, mgr); 463 pci_set_drvdata(pdev, mgr);
462 464
diff --git a/drivers/misc/ibmasm/ibmasmfs.c b/drivers/misc/ibmasm/ibmasmfs.c
index e05c3245930a..fa840666bdd1 100644
--- a/drivers/misc/ibmasm/ibmasmfs.c
+++ b/drivers/misc/ibmasm/ibmasmfs.c
@@ -507,35 +507,14 @@ static int remote_settings_file_close(struct inode *inode, struct file *file)
507static ssize_t remote_settings_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset) 507static ssize_t remote_settings_file_read(struct file *file, char __user *buf, size_t count, loff_t *offset)
508{ 508{
509 void __iomem *address = (void __iomem *)file->private_data; 509 void __iomem *address = (void __iomem *)file->private_data;
510 unsigned char *page;
511 int retval;
512 int len = 0; 510 int len = 0;
513 unsigned int value; 511 unsigned int value;
514 512 char lbuf[20];
515 if (*offset < 0)
516 return -EINVAL;
517 if (count == 0 || count > 1024)
518 return 0;
519 if (*offset != 0)
520 return 0;
521
522 page = (unsigned char *)__get_free_page(GFP_KERNEL);
523 if (!page)
524 return -ENOMEM;
525 513
526 value = readl(address); 514 value = readl(address);
527 len = sprintf(page, "%d\n", value); 515 len = snprintf(lbuf, sizeof(lbuf), "%d\n", value);
528
529 if (copy_to_user(buf, page, len)) {
530 retval = -EFAULT;
531 goto exit;
532 }
533 *offset += len;
534 retval = len;
535 516
536exit: 517 return simple_read_from_buffer(buf, count, offset, lbuf, len);
537 free_page((unsigned long)page);
538 return retval;
539} 518}
540 519
541static ssize_t remote_settings_file_write(struct file *file, const char __user *ubuff, size_t count, loff_t *offset) 520static ssize_t remote_settings_file_write(struct file *file, const char __user *ubuff, size_t count, loff_t *offset)
diff --git a/drivers/misc/mei/interrupt.c b/drivers/misc/mei/interrupt.c
index b0b8f18a85e3..6649f0d56d2f 100644
--- a/drivers/misc/mei/interrupt.c
+++ b/drivers/misc/mei/interrupt.c
@@ -310,8 +310,11 @@ int mei_irq_read_handler(struct mei_device *dev,
310 if (&cl->link == &dev->file_list) { 310 if (&cl->link == &dev->file_list) {
311 /* A message for not connected fixed address clients 311 /* A message for not connected fixed address clients
312 * should be silently discarded 312 * should be silently discarded
313 * On power down client may be force cleaned,
314 * silently discard such messages
313 */ 315 */
314 if (hdr_is_fixed(mei_hdr)) { 316 if (hdr_is_fixed(mei_hdr) ||
317 dev->dev_state == MEI_DEV_POWER_DOWN) {
315 mei_irq_discard_msg(dev, mei_hdr); 318 mei_irq_discard_msg(dev, mei_hdr);
316 ret = 0; 319 ret = 0;
317 goto reset_slots; 320 goto reset_slots;
diff --git a/drivers/misc/vmw_balloon.c b/drivers/misc/vmw_balloon.c
index efd733472a35..56c6f79a5c5a 100644
--- a/drivers/misc/vmw_balloon.c
+++ b/drivers/misc/vmw_balloon.c
@@ -467,7 +467,7 @@ static int vmballoon_send_batched_lock(struct vmballoon *b,
467 unsigned int num_pages, bool is_2m_pages, unsigned int *target) 467 unsigned int num_pages, bool is_2m_pages, unsigned int *target)
468{ 468{
469 unsigned long status; 469 unsigned long status;
470 unsigned long pfn = page_to_pfn(b->page); 470 unsigned long pfn = PHYS_PFN(virt_to_phys(b->batch_page));
471 471
472 STATS_INC(b->stats.lock[is_2m_pages]); 472 STATS_INC(b->stats.lock[is_2m_pages]);
473 473
@@ -515,7 +515,7 @@ static bool vmballoon_send_batched_unlock(struct vmballoon *b,
515 unsigned int num_pages, bool is_2m_pages, unsigned int *target) 515 unsigned int num_pages, bool is_2m_pages, unsigned int *target)
516{ 516{
517 unsigned long status; 517 unsigned long status;
518 unsigned long pfn = page_to_pfn(b->page); 518 unsigned long pfn = PHYS_PFN(virt_to_phys(b->batch_page));
519 519
520 STATS_INC(b->stats.unlock[is_2m_pages]); 520 STATS_INC(b->stats.unlock[is_2m_pages]);
521 521
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index b5b0cdc21d01..514d1dfc5630 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -936,6 +936,10 @@ struct nvmem_cell *nvmem_cell_get(struct device *dev, const char *cell_id)
936 return cell; 936 return cell;
937 } 937 }
938 938
939 /* NULL cell_id only allowed for device tree; invalid otherwise */
940 if (!cell_id)
941 return ERR_PTR(-EINVAL);
942
939 return nvmem_cell_get_from_list(cell_id); 943 return nvmem_cell_get_from_list(cell_id);
940} 944}
941EXPORT_SYMBOL_GPL(nvmem_cell_get); 945EXPORT_SYMBOL_GPL(nvmem_cell_get);
diff --git a/drivers/thunderbolt/domain.c b/drivers/thunderbolt/domain.c
index 6281266b8ec0..a923ebdeb73c 100644
--- a/drivers/thunderbolt/domain.c
+++ b/drivers/thunderbolt/domain.c
@@ -213,6 +213,10 @@ static ssize_t boot_acl_store(struct device *dev, struct device_attribute *attr,
213 goto err_free_acl; 213 goto err_free_acl;
214 } 214 }
215 ret = tb->cm_ops->set_boot_acl(tb, acl, tb->nboot_acl); 215 ret = tb->cm_ops->set_boot_acl(tb, acl, tb->nboot_acl);
216 if (!ret) {
217 /* Notify userspace about the change */
218 kobject_uevent(&tb->dev.kobj, KOBJ_CHANGE);
219 }
216 mutex_unlock(&tb->lock); 220 mutex_unlock(&tb->lock);
217 221
218err_free_acl: 222err_free_acl:
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index e8f4ac9400ea..5d421d7e8904 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -215,7 +215,20 @@ static ssize_t name_show(struct device *dev,
215 struct device_attribute *attr, char *buf) 215 struct device_attribute *attr, char *buf)
216{ 216{
217 struct uio_device *idev = dev_get_drvdata(dev); 217 struct uio_device *idev = dev_get_drvdata(dev);
218 return sprintf(buf, "%s\n", idev->info->name); 218 int ret;
219
220 mutex_lock(&idev->info_lock);
221 if (!idev->info) {
222 ret = -EINVAL;
223 dev_err(dev, "the device has been unregistered\n");
224 goto out;
225 }
226
227 ret = sprintf(buf, "%s\n", idev->info->name);
228
229out:
230 mutex_unlock(&idev->info_lock);
231 return ret;
219} 232}
220static DEVICE_ATTR_RO(name); 233static DEVICE_ATTR_RO(name);
221 234
@@ -223,7 +236,20 @@ static ssize_t version_show(struct device *dev,
223 struct device_attribute *attr, char *buf) 236 struct device_attribute *attr, char *buf)
224{ 237{
225 struct uio_device *idev = dev_get_drvdata(dev); 238 struct uio_device *idev = dev_get_drvdata(dev);
226 return sprintf(buf, "%s\n", idev->info->version); 239 int ret;
240
241 mutex_lock(&idev->info_lock);
242 if (!idev->info) {
243 ret = -EINVAL;
244 dev_err(dev, "the device has been unregistered\n");
245 goto out;
246 }
247
248 ret = sprintf(buf, "%s\n", idev->info->version);
249
250out:
251 mutex_unlock(&idev->info_lock);
252 return ret;
227} 253}
228static DEVICE_ATTR_RO(version); 254static DEVICE_ATTR_RO(version);
229 255
@@ -415,11 +441,15 @@ EXPORT_SYMBOL_GPL(uio_event_notify);
415static irqreturn_t uio_interrupt(int irq, void *dev_id) 441static irqreturn_t uio_interrupt(int irq, void *dev_id)
416{ 442{
417 struct uio_device *idev = (struct uio_device *)dev_id; 443 struct uio_device *idev = (struct uio_device *)dev_id;
418 irqreturn_t ret = idev->info->handler(irq, idev->info); 444 irqreturn_t ret;
419 445
446 mutex_lock(&idev->info_lock);
447
448 ret = idev->info->handler(irq, idev->info);
420 if (ret == IRQ_HANDLED) 449 if (ret == IRQ_HANDLED)
421 uio_event_notify(idev->info); 450 uio_event_notify(idev->info);
422 451
452 mutex_unlock(&idev->info_lock);
423 return ret; 453 return ret;
424} 454}
425 455
@@ -433,7 +463,6 @@ static int uio_open(struct inode *inode, struct file *filep)
433 struct uio_device *idev; 463 struct uio_device *idev;
434 struct uio_listener *listener; 464 struct uio_listener *listener;
435 int ret = 0; 465 int ret = 0;
436 unsigned long flags;
437 466
438 mutex_lock(&minor_lock); 467 mutex_lock(&minor_lock);
439 idev = idr_find(&uio_idr, iminor(inode)); 468 idev = idr_find(&uio_idr, iminor(inode));
@@ -460,10 +489,16 @@ static int uio_open(struct inode *inode, struct file *filep)
460 listener->event_count = atomic_read(&idev->event); 489 listener->event_count = atomic_read(&idev->event);
461 filep->private_data = listener; 490 filep->private_data = listener;
462 491
463 spin_lock_irqsave(&idev->info_lock, flags); 492 mutex_lock(&idev->info_lock);
493 if (!idev->info) {
494 mutex_unlock(&idev->info_lock);
495 ret = -EINVAL;
496 goto err_alloc_listener;
497 }
498
464 if (idev->info && idev->info->open) 499 if (idev->info && idev->info->open)
465 ret = idev->info->open(idev->info, inode); 500 ret = idev->info->open(idev->info, inode);
466 spin_unlock_irqrestore(&idev->info_lock, flags); 501 mutex_unlock(&idev->info_lock);
467 if (ret) 502 if (ret)
468 goto err_infoopen; 503 goto err_infoopen;
469 504
@@ -495,12 +530,11 @@ static int uio_release(struct inode *inode, struct file *filep)
495 int ret = 0; 530 int ret = 0;
496 struct uio_listener *listener = filep->private_data; 531 struct uio_listener *listener = filep->private_data;
497 struct uio_device *idev = listener->dev; 532 struct uio_device *idev = listener->dev;
498 unsigned long flags;
499 533
500 spin_lock_irqsave(&idev->info_lock, flags); 534 mutex_lock(&idev->info_lock);
501 if (idev->info && idev->info->release) 535 if (idev->info && idev->info->release)
502 ret = idev->info->release(idev->info, inode); 536 ret = idev->info->release(idev->info, inode);
503 spin_unlock_irqrestore(&idev->info_lock, flags); 537 mutex_unlock(&idev->info_lock);
504 538
505 module_put(idev->owner); 539 module_put(idev->owner);
506 kfree(listener); 540 kfree(listener);
@@ -513,12 +547,11 @@ static __poll_t uio_poll(struct file *filep, poll_table *wait)
513 struct uio_listener *listener = filep->private_data; 547 struct uio_listener *listener = filep->private_data;
514 struct uio_device *idev = listener->dev; 548 struct uio_device *idev = listener->dev;
515 __poll_t ret = 0; 549 __poll_t ret = 0;
516 unsigned long flags;
517 550
518 spin_lock_irqsave(&idev->info_lock, flags); 551 mutex_lock(&idev->info_lock);
519 if (!idev->info || !idev->info->irq) 552 if (!idev->info || !idev->info->irq)
520 ret = -EIO; 553 ret = -EIO;
521 spin_unlock_irqrestore(&idev->info_lock, flags); 554 mutex_unlock(&idev->info_lock);
522 555
523 if (ret) 556 if (ret)
524 return ret; 557 return ret;
@@ -537,12 +570,11 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
537 DECLARE_WAITQUEUE(wait, current); 570 DECLARE_WAITQUEUE(wait, current);
538 ssize_t retval = 0; 571 ssize_t retval = 0;
539 s32 event_count; 572 s32 event_count;
540 unsigned long flags;
541 573
542 spin_lock_irqsave(&idev->info_lock, flags); 574 mutex_lock(&idev->info_lock);
543 if (!idev->info || !idev->info->irq) 575 if (!idev->info || !idev->info->irq)
544 retval = -EIO; 576 retval = -EIO;
545 spin_unlock_irqrestore(&idev->info_lock, flags); 577 mutex_unlock(&idev->info_lock);
546 578
547 if (retval) 579 if (retval)
548 return retval; 580 return retval;
@@ -592,9 +624,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
592 struct uio_device *idev = listener->dev; 624 struct uio_device *idev = listener->dev;
593 ssize_t retval; 625 ssize_t retval;
594 s32 irq_on; 626 s32 irq_on;
595 unsigned long flags;
596 627
597 spin_lock_irqsave(&idev->info_lock, flags); 628 mutex_lock(&idev->info_lock);
629 if (!idev->info) {
630 retval = -EINVAL;
631 goto out;
632 }
633
598 if (!idev->info || !idev->info->irq) { 634 if (!idev->info || !idev->info->irq) {
599 retval = -EIO; 635 retval = -EIO;
600 goto out; 636 goto out;
@@ -618,7 +654,7 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
618 retval = idev->info->irqcontrol(idev->info, irq_on); 654 retval = idev->info->irqcontrol(idev->info, irq_on);
619 655
620out: 656out:
621 spin_unlock_irqrestore(&idev->info_lock, flags); 657 mutex_unlock(&idev->info_lock);
622 return retval ? retval : sizeof(s32); 658 return retval ? retval : sizeof(s32);
623} 659}
624 660
@@ -640,10 +676,20 @@ static vm_fault_t uio_vma_fault(struct vm_fault *vmf)
640 struct page *page; 676 struct page *page;
641 unsigned long offset; 677 unsigned long offset;
642 void *addr; 678 void *addr;
679 int ret = 0;
680 int mi;
643 681
644 int mi = uio_find_mem_index(vmf->vma); 682 mutex_lock(&idev->info_lock);
645 if (mi < 0) 683 if (!idev->info) {
646 return VM_FAULT_SIGBUS; 684 ret = VM_FAULT_SIGBUS;
685 goto out;
686 }
687
688 mi = uio_find_mem_index(vmf->vma);
689 if (mi < 0) {
690 ret = VM_FAULT_SIGBUS;
691 goto out;
692 }
647 693
648 /* 694 /*
649 * We need to subtract mi because userspace uses offset = N*PAGE_SIZE 695 * We need to subtract mi because userspace uses offset = N*PAGE_SIZE
@@ -658,7 +704,11 @@ static vm_fault_t uio_vma_fault(struct vm_fault *vmf)
658 page = vmalloc_to_page(addr); 704 page = vmalloc_to_page(addr);
659 get_page(page); 705 get_page(page);
660 vmf->page = page; 706 vmf->page = page;
661 return 0; 707
708out:
709 mutex_unlock(&idev->info_lock);
710
711 return ret;
662} 712}
663 713
664static const struct vm_operations_struct uio_logical_vm_ops = { 714static const struct vm_operations_struct uio_logical_vm_ops = {
@@ -683,6 +733,7 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
683 struct uio_device *idev = vma->vm_private_data; 733 struct uio_device *idev = vma->vm_private_data;
684 int mi = uio_find_mem_index(vma); 734 int mi = uio_find_mem_index(vma);
685 struct uio_mem *mem; 735 struct uio_mem *mem;
736
686 if (mi < 0) 737 if (mi < 0)
687 return -EINVAL; 738 return -EINVAL;
688 mem = idev->info->mem + mi; 739 mem = idev->info->mem + mi;
@@ -724,30 +775,46 @@ static int uio_mmap(struct file *filep, struct vm_area_struct *vma)
724 775
725 vma->vm_private_data = idev; 776 vma->vm_private_data = idev;
726 777
778 mutex_lock(&idev->info_lock);
779 if (!idev->info) {
780 ret = -EINVAL;
781 goto out;
782 }
783
727 mi = uio_find_mem_index(vma); 784 mi = uio_find_mem_index(vma);
728 if (mi < 0) 785 if (mi < 0) {
729 return -EINVAL; 786 ret = -EINVAL;
787 goto out;
788 }
730 789
731 requested_pages = vma_pages(vma); 790 requested_pages = vma_pages(vma);
732 actual_pages = ((idev->info->mem[mi].addr & ~PAGE_MASK) 791 actual_pages = ((idev->info->mem[mi].addr & ~PAGE_MASK)
733 + idev->info->mem[mi].size + PAGE_SIZE -1) >> PAGE_SHIFT; 792 + idev->info->mem[mi].size + PAGE_SIZE -1) >> PAGE_SHIFT;
734 if (requested_pages > actual_pages) 793 if (requested_pages > actual_pages) {
735 return -EINVAL; 794 ret = -EINVAL;
795 goto out;
796 }
736 797
737 if (idev->info->mmap) { 798 if (idev->info->mmap) {
738 ret = idev->info->mmap(idev->info, vma); 799 ret = idev->info->mmap(idev->info, vma);
739 return ret; 800 goto out;
740 } 801 }
741 802
742 switch (idev->info->mem[mi].memtype) { 803 switch (idev->info->mem[mi].memtype) {
743 case UIO_MEM_PHYS: 804 case UIO_MEM_PHYS:
744 return uio_mmap_physical(vma); 805 ret = uio_mmap_physical(vma);
806 break;
745 case UIO_MEM_LOGICAL: 807 case UIO_MEM_LOGICAL:
746 case UIO_MEM_VIRTUAL: 808 case UIO_MEM_VIRTUAL:
747 return uio_mmap_logical(vma); 809 ret = uio_mmap_logical(vma);
810 break;
748 default: 811 default:
749 return -EINVAL; 812 ret = -EINVAL;
750 } 813 }
814
815out:
816 mutex_unlock(&idev->info_lock);
817 return 0;
751} 818}
752 819
753static const struct file_operations uio_fops = { 820static const struct file_operations uio_fops = {
@@ -865,7 +932,7 @@ int __uio_register_device(struct module *owner,
865 932
866 idev->owner = owner; 933 idev->owner = owner;
867 idev->info = info; 934 idev->info = info;
868 spin_lock_init(&idev->info_lock); 935 mutex_init(&idev->info_lock);
869 init_waitqueue_head(&idev->wait); 936 init_waitqueue_head(&idev->wait);
870 atomic_set(&idev->event, 0); 937 atomic_set(&idev->event, 0);
871 938
@@ -902,8 +969,9 @@ int __uio_register_device(struct module *owner,
902 * FDs at the time of unregister and therefore may not be 969 * FDs at the time of unregister and therefore may not be
903 * freed until they are released. 970 * freed until they are released.
904 */ 971 */
905 ret = request_irq(info->irq, uio_interrupt, 972 ret = request_threaded_irq(info->irq, NULL, uio_interrupt,
906 info->irq_flags, info->name, idev); 973 info->irq_flags, info->name, idev);
974
907 if (ret) 975 if (ret)
908 goto err_request_irq; 976 goto err_request_irq;
909 } 977 }
@@ -928,7 +996,6 @@ EXPORT_SYMBOL_GPL(__uio_register_device);
928void uio_unregister_device(struct uio_info *info) 996void uio_unregister_device(struct uio_info *info)
929{ 997{
930 struct uio_device *idev; 998 struct uio_device *idev;
931 unsigned long flags;
932 999
933 if (!info || !info->uio_dev) 1000 if (!info || !info->uio_dev)
934 return; 1001 return;
@@ -937,14 +1004,14 @@ void uio_unregister_device(struct uio_info *info)
937 1004
938 uio_free_minor(idev); 1005 uio_free_minor(idev);
939 1006
1007 mutex_lock(&idev->info_lock);
940 uio_dev_del_attributes(idev); 1008 uio_dev_del_attributes(idev);
941 1009
942 if (info->irq && info->irq != UIO_IRQ_CUSTOM) 1010 if (info->irq && info->irq != UIO_IRQ_CUSTOM)
943 free_irq(info->irq, idev); 1011 free_irq(info->irq, idev);
944 1012
945 spin_lock_irqsave(&idev->info_lock, flags);
946 idev->info = NULL; 1013 idev->info = NULL;
947 spin_unlock_irqrestore(&idev->info_lock, flags); 1014 mutex_unlock(&idev->info_lock);
948 1015
949 device_unregister(&idev->dev); 1016 device_unregister(&idev->dev);
950 1017
diff --git a/include/linux/uio_driver.h b/include/linux/uio_driver.h
index 6c5f2074e14f..6f8b68cd460f 100644
--- a/include/linux/uio_driver.h
+++ b/include/linux/uio_driver.h
@@ -75,7 +75,7 @@ struct uio_device {
75 struct fasync_struct *async_queue; 75 struct fasync_struct *async_queue;
76 wait_queue_head_t wait; 76 wait_queue_head_t wait;
77 struct uio_info *info; 77 struct uio_info *info;
78 spinlock_t info_lock; 78 struct mutex info_lock;
79 struct kobject *map_dir; 79 struct kobject *map_dir;
80 struct kobject *portio_dir; 80 struct kobject *portio_dir;
81}; 81};