diff options
Diffstat (limited to 'drivers/pcmcia/pcmcia_ioctl.c')
-rw-r--r-- | drivers/pcmcia/pcmcia_ioctl.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/drivers/pcmcia/pcmcia_ioctl.c b/drivers/pcmcia/pcmcia_ioctl.c index afd00e7bbbef..419f97fc9a62 100644 --- a/drivers/pcmcia/pcmcia_ioctl.c +++ b/drivers/pcmcia/pcmcia_ioctl.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/proc_fs.h> | 27 | #include <linux/proc_fs.h> |
28 | #include <linux/poll.h> | 28 | #include <linux/poll.h> |
29 | #include <linux/pci.h> | 29 | #include <linux/pci.h> |
30 | #include <linux/smp_lock.h> | ||
30 | #include <linux/workqueue.h> | 31 | #include <linux/workqueue.h> |
31 | 32 | ||
32 | #include <pcmcia/cs_types.h> | 33 | #include <pcmcia/cs_types.h> |
@@ -545,20 +546,27 @@ static int ds_open(struct inode *inode, struct file *file) | |||
545 | struct pcmcia_socket *s; | 546 | struct pcmcia_socket *s; |
546 | user_info_t *user; | 547 | user_info_t *user; |
547 | static int warning_printed = 0; | 548 | static int warning_printed = 0; |
549 | int ret = 0; | ||
548 | 550 | ||
549 | ds_dbg(0, "ds_open(socket %d)\n", i); | 551 | ds_dbg(0, "ds_open(socket %d)\n", i); |
550 | 552 | ||
553 | lock_kernel(); | ||
551 | s = pcmcia_get_socket_by_nr(i); | 554 | s = pcmcia_get_socket_by_nr(i); |
552 | if (!s) | 555 | if (!s) { |
553 | return -ENODEV; | 556 | ret = -ENODEV; |
557 | goto out; | ||
558 | } | ||
554 | s = pcmcia_get_socket(s); | 559 | s = pcmcia_get_socket(s); |
555 | if (!s) | 560 | if (!s) { |
556 | return -ENODEV; | 561 | ret = -ENODEV; |
562 | goto out; | ||
563 | } | ||
557 | 564 | ||
558 | if ((file->f_flags & O_ACCMODE) != O_RDONLY) { | 565 | if ((file->f_flags & O_ACCMODE) != O_RDONLY) { |
559 | if (s->pcmcia_state.busy) { | 566 | if (s->pcmcia_state.busy) { |
560 | pcmcia_put_socket(s); | 567 | pcmcia_put_socket(s); |
561 | return -EBUSY; | 568 | ret = -EBUSY; |
569 | goto out; | ||
562 | } | 570 | } |
563 | else | 571 | else |
564 | s->pcmcia_state.busy = 1; | 572 | s->pcmcia_state.busy = 1; |
@@ -567,7 +575,8 @@ static int ds_open(struct inode *inode, struct file *file) | |||
567 | user = kmalloc(sizeof(user_info_t), GFP_KERNEL); | 575 | user = kmalloc(sizeof(user_info_t), GFP_KERNEL); |
568 | if (!user) { | 576 | if (!user) { |
569 | pcmcia_put_socket(s); | 577 | pcmcia_put_socket(s); |
570 | return -ENOMEM; | 578 | ret = -ENOMEM; |
579 | goto out; | ||
571 | } | 580 | } |
572 | user->event_tail = user->event_head = 0; | 581 | user->event_tail = user->event_head = 0; |
573 | user->next = s->user; | 582 | user->next = s->user; |
@@ -589,7 +598,9 @@ static int ds_open(struct inode *inode, struct file *file) | |||
589 | 598 | ||
590 | if (s->pcmcia_state.present) | 599 | if (s->pcmcia_state.present) |
591 | queue_event(user, CS_EVENT_CARD_INSERTION); | 600 | queue_event(user, CS_EVENT_CARD_INSERTION); |
592 | return 0; | 601 | out: |
602 | unlock_kernel(); | ||
603 | return ret; | ||
593 | } /* ds_open */ | 604 | } /* ds_open */ |
594 | 605 | ||
595 | /*====================================================================*/ | 606 | /*====================================================================*/ |