From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756172AbbBEAgu (ORCPT ); Wed, 4 Feb 2015 19:36:50 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:52261 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755922AbbBEAgr (ORCPT ); Wed, 4 Feb 2015 19:36:47 -0500 Date: Thu, 5 Feb 2015 09:36:46 +0900 From: Sergey Senozhatsky To: Andrew Morton Cc: Sergey Senozhatsky , linux-kernel@vger.kernel.org, jmarchan@redhat.com, minchan@kernel.org, ngupta@vflare.org, opensource.ganesh@gmail.com, sergey.senozhatsky@gmail.com, mm-commits@vger.kernel.org Subject: Re: + zram-rework-reset-and-destroy-path-fix.patch added to -mm tree Message-ID: <20150205003424.GA462@swordfish> References: <54d155bf.k9GCVwDVqT17beYC%akpm@linux-foundation.org> <20150204010720.GC527@swordfish> <20150204142959.de8ddfef8374132b27a5d0c2@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150204142959.de8ddfef8374132b27a5d0c2@linux-foundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; > }