lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <1446812535-10567-4-git-send-email-vishnu.ps@samsung.com>
Date:	Fri, 06 Nov 2015 17:52:11 +0530
From:	Vishnu Pratap Singh <vishnu.ps@...sung.com>
To:	axboe@...nel.dk, akpm@...ux-foundation.org,
	linux-kernel@...r.kernel.org, jmoyer@...hat.com,
	minchan@...nel.org, ngupta@...are.org,
	sergey.senozhatsky.work@...il.com, davem@...emloft.net,
	neilb@...e.com, ulf.hansson@...aro.org, tiwai@...e.de,
	hare@...e.de, ming.lei@...onical.com, jarod@...hat.com,
	viro@...iv.linux.org.uk, tj@...nel.org, adrian.hunter@...el.com,
	jonathanh@...dia.com, grundler@...omium.org,
	linux-ide@...r.kernel.org, linux-raid@...r.kernel.org,
	linux-mmc@...r.kernel.org
Cc:	cpgs@...sung.com, vishu13285@...il.com, pintu.k@...sung.com,
	rohit.kr@...sung.com, Vishnu Pratap Singh <vishnu.ps@...sung.com>
Subject: [PATCH 4/8] block/loop.c: handle add_disk() & blk_register_region()
 return value

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@...sung.com>
---
 drivers/block/loop.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 423f4ca..22e6fd0 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1794,10 +1794,14 @@ static int loop_add(struct loop_device **l, int i)
 	disk->private_data	= lo;
 	disk->queue		= lo->lo_queue;
 	sprintf(disk->disk_name, "loop%d", i);
-	add_disk(disk);
+	err = add_disk(disk);
+	if (err)
+		goto out_free_disk;
 	*l = lo;
 	return lo->lo_number;
 
+out_free_disk:
+	put_disk(disk);
 out_free_queue:
 	blk_cleanup_queue(lo->lo_queue);
 out_cleanup_tags:
@@ -1998,8 +2002,10 @@ static int __init loop_init(void)
 		goto misc_out;
 	}
 
-	blk_register_region(MKDEV(LOOP_MAJOR, 0), range,
+	err = blk_register_region(MKDEV(LOOP_MAJOR, 0), range,
 				  THIS_MODULE, loop_probe, NULL, NULL);
+	if (err)
+		goto out_blkdev;
 
 	/* pre-create number of devices given by config or max_loop */
 	mutex_lock(&loop_index_mutex);
@@ -2010,6 +2016,8 @@ static int __init loop_init(void)
 	printk(KERN_INFO "loop: module loaded\n");
 	return 0;
 
+out_blkdev:
+	unregister_blkdev(LOOP_MAJOR, "loop");
 misc_out:
 	misc_deregister(&loop_misc);
 	return err;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ