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: <0999c39931090daa5a78996039b5d58812a71e34.1442263512.git.lduncan@suse.com>
Date:	Tue, 15 Sep 2015 09:46:03 -0700
From:	Lee Duncan <lduncan@...e.com>
To:	<linux-scsi@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Cc:	Hannes Reinecke <hare@...e.com>,
	Johannes Thumshirn <jthumshirn@...e.de>,
	Christoph Hellwig <hch@...radead.org>,
	Lee Duncan <lduncan@...e.com>, Kai.Makisara@...umbus.fi
Subject: [PATCH 03/17] Update the st driver to use idr helper functions.

Signed-off-by: Lee Duncan <lduncan@...e.com>
---
 drivers/scsi/st.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index b37b9b00c4b4..51e1ce721d9f 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -4265,11 +4265,8 @@ static int st_probe(struct device *dev)
 	    tpnt->blksize_changed = 0;
 	mutex_init(&tpnt->lock);
 
-	idr_preload(GFP_KERNEL);
-	spin_lock(&st_index_lock);
-	error = idr_alloc(&st_index_idr, tpnt, 0, ST_MAX_TAPES + 1, GFP_NOWAIT);
-	spin_unlock(&st_index_lock);
-	idr_preload_end();
+	error = idr_get_index_in_range(&st_index_idr, &st_index_lock, tpnt,
+				       0, ST_MAX_TAPES + 1);
 	if (error < 0) {
 		pr_warn("st: idr allocation failed: %d\n", error);
 		goto out_put_queue;
@@ -4303,9 +4300,7 @@ out_remove_devs:
 	remove_cdevs(tpnt);
 	kfree(tpnt->stats);
 out_idr_remove:
-	spin_lock(&st_index_lock);
-	idr_remove(&st_index_idr, tpnt->index);
-	spin_unlock(&st_index_lock);
+	idr_put_index(&st_index_idr, &st_index_lock, tpnt->index);
 out_put_queue:
 	blk_put_queue(disk->queue);
 out_put_disk:
@@ -4330,9 +4325,7 @@ static int st_remove(struct device *dev)
 	mutex_lock(&st_ref_mutex);
 	kref_put(&tpnt->kref, scsi_tape_release);
 	mutex_unlock(&st_ref_mutex);
-	spin_lock(&st_index_lock);
-	idr_remove(&st_index_idr, index);
-	spin_unlock(&st_index_lock);
+	idr_put_index(&st_index_idr, &st_index_lock, index);
 	return 0;
 }
 
-- 
2.1.4

--
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