All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vishnu Pratap Singh <vishnu.ps@samsung.com>
To: axboe@kernel.dk, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org, jmoyer@redhat.com,
	minchan@kernel.org, ngupta@vflare.org,
	sergey.senozhatsky.work@gmail.com, davem@davemloft.net,
	neilb@suse.com, ulf.hansson@linaro.org, tiwai@suse.de,
	hare@suse.de, ming.lei@canonical.com, jarod@redhat.com,
	viro@zeniv.linux.org.uk, tj@kernel.org, adrian.hunter@intel.com,
	jonathanh@nvidia.com, grundler@chromium.org,
	linux-ide@vger.kernel.org, linux-raid@vger.kernel.org,
	linux-mmc@vger.kernel.org
Cc: cpgs@samsung.com, vishu13285@gmail.com, pintu.k@samsung.com,
	rohit.kr@samsung.com, Vishnu Pratap Singh <vishnu.ps@samsung.com>
Subject: [PATCH 5/8] zram: handle add_disk() & blk_register_region() return value
Date: Fri, 06 Nov 2015 17:52:12 +0530	[thread overview]
Message-ID: <1446812535-10567-5-git-send-email-vishnu.ps@samsung.com> (raw)
In-Reply-To: <1446812535-10567-1-git-send-email-vishnu.ps@samsung.com>

This patch handles blk_register_region() & add_disk() return value.
Earlier these function doesn't handle error cases, now it is added,
so the callers of this function should also handle it.

Verfied on X86 based ubuntu machine.
This patch depends on [PATCH 1/8] block/genhd.c: Add error handling

Signed-off-by: Vishnu Pratap Singh <vishnu.ps@samsung.com>
---
 drivers/block/z2ram.c         | 12 ++++++++++--
 drivers/block/zram/zram_drv.c |  9 ++++++---
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index 968f9e5..85e841f 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -364,12 +364,20 @@ z2_init(void)
     sprintf(z2ram_gendisk->disk_name, "z2ram");
 
     z2ram_gendisk->queue = z2_queue;
-    add_disk(z2ram_gendisk);
-    blk_register_region(MKDEV(Z2RAM_MAJOR, 0), Z2MINOR_COUNT, THIS_MODULE,
+    ret = add_disk(z2ram_gendisk);
+    if (ret)
+	goto out_add_disk;
+
+    ret = blk_register_region(MKDEV(Z2RAM_MAJOR, 0), Z2MINOR_COUNT, THIS_MODULE,
 				z2_find, NULL, NULL);
+    if (ret)
+	goto out_blk_reg;
 
     return 0;
 
+out_blk_reg:
+	del_gendisk(z2ram_gendisk);
+out_add_disk:
 out_queue:
     put_disk(z2ram_gendisk);
 out_disk:
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 81a557c..f3d7a49 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1261,14 +1261,16 @@ static int zram_add(void)
 		zram->disk->queue->limits.discard_zeroes_data = 0;
 	queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, zram->disk->queue);
 
-	add_disk(zram->disk);
+	ret = add_disk(zram->disk);
+	if (ret)
+		goto out_free_disk;
 
 	ret = sysfs_create_group(&disk_to_dev(zram->disk)->kobj,
 				&zram_disk_attr_group);
 	if (ret < 0) {
 		pr_err("Error creating sysfs group for device %d\n",
 				device_id);
-		goto out_free_disk;
+		goto out_del_disk;
 	}
 	strlcpy(zram->compressor, default_compressor, sizeof(zram->compressor));
 	zram->meta = NULL;
@@ -1277,8 +1279,9 @@ static int zram_add(void)
 	pr_info("Added device: %s\n", zram->disk->disk_name);
 	return device_id;
 
-out_free_disk:
+out_del_disk:
 	del_gendisk(zram->disk);
+out_free_disk:
 	put_disk(zram->disk);
 out_free_queue:
 	blk_cleanup_queue(queue);
-- 
1.9.1


  parent reply	other threads:[~2015-11-06 12:22 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <437969438-9181-1-git-send-email-vishnu.ps@samsung.com>
2015-11-06 12:22 ` [PATCH 1/8] block/genhd.c: Add error handling Vishnu Pratap Singh
2015-11-06 12:22   ` [PATCH 2/8] mmc: handle add_disk() return value Vishnu Pratap Singh
2015-11-06 16:03     ` Ulf Hansson
2015-11-09  5:11     ` Vishnu Pratap Singh
2015-11-06 12:22   ` [PATCH 3/8] block/floppy.c: handle blk_register_region() " Vishnu Pratap Singh
2015-11-06 12:50     ` kbuild test robot
2015-11-06 12:50       ` kbuild test robot
2015-11-09  3:16     ` Vishnu Pratap Singh
2015-11-09 23:44     ` Grant Grundler
2015-11-10  3:25     ` [PATCH v2] " Vishnu Pratap Singh
2015-11-10  8:20       ` kbuild test robot
2015-11-10  8:20         ` kbuild test robot
2015-11-06 12:22   ` [PATCH 4/8] block/loop.c: handle add_disk() & " Vishnu Pratap Singh
2015-11-06 12:22   ` Vishnu Pratap Singh [this message]
2015-11-09  1:07     ` [PATCH 5/8] zram: " Sergey Senozhatsky
2015-11-06 12:22   ` [PATCH 6/8] md/md.c: handle " Vishnu Pratap Singh
2015-11-06 12:22   ` [PATCH 7/8] cdrom/gdrom.c: handle add_disk() " Vishnu Pratap Singh
2015-11-06 12:22   ` [PATCH 8/8] ide/ide-probe.c: handle blk_register_region() " Vishnu Pratap Singh
2015-11-10  3:33   ` [PATCH 1/8] block/genhd.c: Add error handling Al Viro
2015-11-10  3:40     ` Jens Axboe
2015-11-10 14:11       ` Jeff Moyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1446812535-10567-5-git-send-email-vishnu.ps@samsung.com \
    --to=vishnu.ps@samsung.com \
    --cc=adrian.hunter@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=cpgs@samsung.com \
    --cc=davem@davemloft.net \
    --cc=grundler@chromium.org \
    --cc=hare@suse.de \
    --cc=jarod@redhat.com \
    --cc=jmoyer@redhat.com \
    --cc=jonathanh@nvidia.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=minchan@kernel.org \
    --cc=ming.lei@canonical.com \
    --cc=neilb@suse.com \
    --cc=ngupta@vflare.org \
    --cc=pintu.k@samsung.com \
    --cc=rohit.kr@samsung.com \
    --cc=sergey.senozhatsky.work@gmail.com \
    --cc=tiwai@suse.de \
    --cc=tj@kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=vishu13285@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.