Re: + zram-rework-reset-and-destroy-path-fix.patch added to -mm tree

From: Sergey Senozhatsky
Date: Wed Feb 04 2015 - 19:36:53 EST


On (02/04/15 14:29), Andrew Morton wrote:
> which yields
>

/* not sure if my previous email has been delived, seems there are some
connectivity problems on my side */


we need to unregister_blkdev(), 'out' label does not do it.

how about the following one (looks simple):

> static int __init zram_init(void)
> {
> int ret;
> int dev_id;
>
> if (num_devices > max_num_devices) {
> pr_warn("Invalid value for num_devices: %u\n",
> num_devices);
> return -EINVAL;
> }
>
> zram_major = register_blkdev(0, "zram");
> if (zram_major <= 0) {
> pr_warn("Unable to get major number\n");
> return -EBUSY;
> }
>
> /* Allocate the device array and initialize each one */
> zram_devices = kzalloc(num_devices * sizeof(struct zram), GFP_KERNEL);
> if (!zram_devices) {
- ret = -ENOMEM;
- goto out_error;
+ unregister_blkdev(zram_major, "zram");
+ return -ENOMEM;
> }
>
> for (dev_id = 0; dev_id < num_devices; dev_id++) {
> ret = create_device(&zram_devices[dev_id], dev_id);
> if (ret)
> goto out_devices;
> }
>
> pr_info("Created %u device(s)\n", num_devices);
> return 0;
>
> out_devices:
> destroy_devices(dev_id);
- out:
> return ret;
> }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/