diff options
| -rw-r--r-- | drivers/block/nbd.c | 10 |
1 files changed, 6 insertions, 4 deletions
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 | ||
