diff options
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/brd.c | 2 | ||||
-rw-r--r-- | drivers/block/nbd.c | 10 | ||||
-rw-r--r-- | drivers/block/pktcdvd.c | 35 |
3 files changed, 17 insertions, 30 deletions
diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 24b97b0bef99..d070d492e385 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c | |||
@@ -571,8 +571,8 @@ out_free: | |||
571 | list_del(&brd->brd_list); | 571 | list_del(&brd->brd_list); |
572 | brd_free(brd); | 572 | brd_free(brd); |
573 | } | 573 | } |
574 | unregister_blkdev(RAMDISK_MAJOR, "ramdisk"); | ||
574 | 575 | ||
575 | unregister_blkdev(RAMDISK_MAJOR, "brd"); | ||
576 | return -ENOMEM; | 576 | return -ENOMEM; |
577 | } | 577 | } |
578 | 578 | ||
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index ad98dda6037d..1778e4a2c672 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -707,15 +707,15 @@ static int __init nbd_init(void) | |||
707 | 707 | ||
708 | BUILD_BUG_ON(sizeof(struct nbd_request) != 28); | 708 | BUILD_BUG_ON(sizeof(struct nbd_request) != 28); |
709 | 709 | ||
710 | nbd_dev = kcalloc(nbds_max, sizeof(*nbd_dev), GFP_KERNEL); | ||
711 | if (!nbd_dev) | ||
712 | return -ENOMEM; | ||
713 | |||
714 | if (max_part < 0) { | 710 | if (max_part < 0) { |
715 | printk(KERN_CRIT "nbd: max_part must be >= 0\n"); | 711 | printk(KERN_CRIT "nbd: max_part must be >= 0\n"); |
716 | return -EINVAL; | 712 | return -EINVAL; |
717 | } | 713 | } |
718 | 714 | ||
715 | nbd_dev = kcalloc(nbds_max, sizeof(*nbd_dev), GFP_KERNEL); | ||
716 | if (!nbd_dev) | ||
717 | return -ENOMEM; | ||
718 | |||
719 | part_shift = 0; | 719 | part_shift = 0; |
720 | if (max_part > 0) | 720 | if (max_part > 0) |
721 | part_shift = fls(max_part); | 721 | part_shift = fls(max_part); |
@@ -779,6 +779,7 @@ out: | |||
779 | blk_cleanup_queue(nbd_dev[i].disk->queue); | 779 | blk_cleanup_queue(nbd_dev[i].disk->queue); |
780 | put_disk(nbd_dev[i].disk); | 780 | put_disk(nbd_dev[i].disk); |
781 | } | 781 | } |
782 | kfree(nbd_dev); | ||
782 | return err; | 783 | return err; |
783 | } | 784 | } |
784 | 785 | ||
@@ -795,6 +796,7 @@ static void __exit nbd_cleanup(void) | |||
795 | } | 796 | } |
796 | } | 797 | } |
797 | unregister_blkdev(NBD_MAJOR, "nbd"); | 798 | unregister_blkdev(NBD_MAJOR, "nbd"); |
799 | kfree(nbd_dev); | ||
798 | printk(KERN_INFO "nbd: unregistered device at major %d\n", NBD_MAJOR); | 800 | printk(KERN_INFO "nbd: unregistered device at major %d\n", NBD_MAJOR); |
799 | } | 801 | } |
800 | 802 | ||
diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c index 158eed4d5161..29b7a648cc6e 100644 --- a/drivers/block/pktcdvd.c +++ b/drivers/block/pktcdvd.c | |||
@@ -49,7 +49,6 @@ | |||
49 | #include <linux/types.h> | 49 | #include <linux/types.h> |
50 | #include <linux/kernel.h> | 50 | #include <linux/kernel.h> |
51 | #include <linux/kthread.h> | 51 | #include <linux/kthread.h> |
52 | #include <linux/smp_lock.h> | ||
53 | #include <linux/errno.h> | 52 | #include <linux/errno.h> |
54 | #include <linux/spinlock.h> | 53 | #include <linux/spinlock.h> |
55 | #include <linux/file.h> | 54 | #include <linux/file.h> |
@@ -2798,14 +2797,9 @@ out_mem: | |||
2798 | return ret; | 2797 | return ret; |
2799 | } | 2798 | } |
2800 | 2799 | ||
2801 | static long pkt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | 2800 | static int pkt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) |
2802 | { | 2801 | { |
2803 | struct inode *inode = file->f_path.dentry->d_inode; | 2802 | struct pktcdvd_device *pd = inode->i_bdev->bd_disk->private_data; |
2804 | struct pktcdvd_device *pd; | ||
2805 | long ret; | ||
2806 | |||
2807 | lock_kernel(); | ||
2808 | pd = inode->i_bdev->bd_disk->private_data; | ||
2809 | 2803 | ||
2810 | VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, imajor(inode), iminor(inode)); | 2804 | VPRINTK("pkt_ioctl: cmd %x, dev %d:%d\n", cmd, imajor(inode), iminor(inode)); |
2811 | 2805 | ||
@@ -2818,8 +2812,7 @@ static long pkt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
2818 | case CDROM_LAST_WRITTEN: | 2812 | case CDROM_LAST_WRITTEN: |
2819 | case CDROM_SEND_PACKET: | 2813 | case CDROM_SEND_PACKET: |
2820 | case SCSI_IOCTL_SEND_COMMAND: | 2814 | case SCSI_IOCTL_SEND_COMMAND: |
2821 | ret = blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg); | 2815 | return blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg); |
2822 | break; | ||
2823 | 2816 | ||
2824 | case CDROMEJECT: | 2817 | case CDROMEJECT: |
2825 | /* | 2818 | /* |
@@ -2828,15 +2821,14 @@ static long pkt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
2828 | */ | 2821 | */ |
2829 | if (pd->refcnt == 1) | 2822 | if (pd->refcnt == 1) |
2830 | pkt_lock_door(pd, 0); | 2823 | pkt_lock_door(pd, 0); |
2831 | ret = blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg); | 2824 | return blkdev_ioctl(pd->bdev->bd_inode, file, cmd, arg); |
2832 | break; | ||
2833 | 2825 | ||
2834 | default: | 2826 | default: |
2835 | VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd); | 2827 | VPRINTK(DRIVER_NAME": Unknown ioctl for %s (%x)\n", pd->name, cmd); |
2836 | ret = -ENOTTY; | 2828 | return -ENOTTY; |
2837 | } | 2829 | } |
2838 | unlock_kernel(); | 2830 | |
2839 | return ret; | 2831 | return 0; |
2840 | } | 2832 | } |
2841 | 2833 | ||
2842 | static int pkt_media_changed(struct gendisk *disk) | 2834 | static int pkt_media_changed(struct gendisk *disk) |
@@ -2858,7 +2850,7 @@ static struct block_device_operations pktcdvd_ops = { | |||
2858 | .owner = THIS_MODULE, | 2850 | .owner = THIS_MODULE, |
2859 | .open = pkt_open, | 2851 | .open = pkt_open, |
2860 | .release = pkt_close, | 2852 | .release = pkt_close, |
2861 | .unlocked_ioctl = pkt_ioctl, | 2853 | .ioctl = pkt_ioctl, |
2862 | .media_changed = pkt_media_changed, | 2854 | .media_changed = pkt_media_changed, |
2863 | }; | 2855 | }; |
2864 | 2856 | ||
@@ -3023,8 +3015,7 @@ static void pkt_get_status(struct pkt_ctrl_command *ctrl_cmd) | |||
3023 | mutex_unlock(&ctl_mutex); | 3015 | mutex_unlock(&ctl_mutex); |
3024 | } | 3016 | } |
3025 | 3017 | ||
3026 | static long pkt_ctl_ioctl(struct file *file, unsigned int cmd, | 3018 | static int pkt_ctl_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) |
3027 | unsigned long arg) | ||
3028 | { | 3019 | { |
3029 | void __user *argp = (void __user *)arg; | 3020 | void __user *argp = (void __user *)arg; |
3030 | struct pkt_ctrl_command ctrl_cmd; | 3021 | struct pkt_ctrl_command ctrl_cmd; |
@@ -3041,22 +3032,16 @@ static long pkt_ctl_ioctl(struct file *file, unsigned int cmd, | |||
3041 | case PKT_CTRL_CMD_SETUP: | 3032 | case PKT_CTRL_CMD_SETUP: |
3042 | if (!capable(CAP_SYS_ADMIN)) | 3033 | if (!capable(CAP_SYS_ADMIN)) |
3043 | return -EPERM; | 3034 | return -EPERM; |
3044 | lock_kernel(); | ||
3045 | ret = pkt_setup_dev(new_decode_dev(ctrl_cmd.dev), &pkt_dev); | 3035 | ret = pkt_setup_dev(new_decode_dev(ctrl_cmd.dev), &pkt_dev); |
3046 | ctrl_cmd.pkt_dev = new_encode_dev(pkt_dev); | 3036 | ctrl_cmd.pkt_dev = new_encode_dev(pkt_dev); |
3047 | unlock_kernel(); | ||
3048 | break; | 3037 | break; |
3049 | case PKT_CTRL_CMD_TEARDOWN: | 3038 | case PKT_CTRL_CMD_TEARDOWN: |
3050 | if (!capable(CAP_SYS_ADMIN)) | 3039 | if (!capable(CAP_SYS_ADMIN)) |
3051 | return -EPERM; | 3040 | return -EPERM; |
3052 | lock_kernel(); | ||
3053 | ret = pkt_remove_dev(new_decode_dev(ctrl_cmd.pkt_dev)); | 3041 | ret = pkt_remove_dev(new_decode_dev(ctrl_cmd.pkt_dev)); |
3054 | unlock_kernel(); | ||
3055 | break; | 3042 | break; |
3056 | case PKT_CTRL_CMD_STATUS: | 3043 | case PKT_CTRL_CMD_STATUS: |
3057 | lock_kernel(); | ||
3058 | pkt_get_status(&ctrl_cmd); | 3044 | pkt_get_status(&ctrl_cmd); |
3059 | unlock_kernel(); | ||
3060 | break; | 3045 | break; |
3061 | default: | 3046 | default: |
3062 | return -ENOTTY; | 3047 | return -ENOTTY; |
@@ -3069,7 +3054,7 @@ static long pkt_ctl_ioctl(struct file *file, unsigned int cmd, | |||
3069 | 3054 | ||
3070 | 3055 | ||
3071 | static const struct file_operations pkt_ctl_fops = { | 3056 | static const struct file_operations pkt_ctl_fops = { |
3072 | .unlocked_ioctl = pkt_ctl_ioctl, | 3057 | .ioctl = pkt_ctl_ioctl, |
3073 | .owner = THIS_MODULE, | 3058 | .owner = THIS_MODULE, |
3074 | }; | 3059 | }; |
3075 | 3060 | ||