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: <20200721105239.8270-11-mlevitsk@redhat.com>
Date:   Tue, 21 Jul 2020 13:52:39 +0300
From:   Maxim Levitsky <mlevitsk@...hat.com>
To:     linux-kernel@...r.kernel.org
Cc:     Keith Busch <kbusch@...nel.org>,
        Josef Bacik <josef@...icpanda.com>,
        linux-block@...r.kernel.org (open list:BLOCK LAYER),
        Sagi Grimberg <sagi@...mberg.me>, Jens Axboe <axboe@...nel.dk>,
        linux-nvme@...ts.infradead.org (open list:NVM EXPRESS DRIVER),
        linux-scsi@...r.kernel.org (open list:SCSI CDROM DRIVER),
        Tejun Heo <tj@...nel.org>,
        Bart Van Assche <bvanassche@....org>,
        "Martin K. Petersen" <martin.petersen@...cle.com>,
        Damien Le Moal <damien.lemoal@....com>,
        Jason Wang <jasowang@...hat.com>,
        Maxim Levitsky <maximlevitsky@...il.com>,
        Stefan Hajnoczi <stefanha@...hat.com>,
        Colin Ian King <colin.king@...onical.com>,
        "Michael S. Tsirkin" <mst@...hat.com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Ulf Hansson <ulf.hansson@...aro.org>,
        Ajay Joshi <ajay.joshi@....com>,
        Ming Lei <ming.lei@...hat.com>,
        linux-mmc@...r.kernel.org (open list:SONY MEMORYSTICK SUBSYSTEM),
        Christoph Hellwig <hch@....de>,
        Satya Tangirala <satyat@...gle.com>,
        nbd@...er.debian.org (open list:NETWORK BLOCK DEVICE (NBD)),
        Hou Tao <houtao1@...wei.com>, Jens Axboe <axboe@...com>,
        virtualization@...ts.linux-foundation.org (open list:VIRTIO CORE AND
        NET DRIVERS), "James E.J. Bottomley" <jejb@...ux.ibm.com>,
        Alex Dubov <oakad@...oo.com>,
        Maxim Levitsky <mlevitsk@...hat.com>
Subject: [PATCH 10/10] block: scsi: sr: use blk_is_valid_logical_block_size

Plus some tiny refactoring.

Signed-off-by: Maxim Levitsky <mlevitsk@...hat.com>
---
 drivers/scsi/sr.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 0c4aa4665a2f9..0e96338029310 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -866,31 +866,26 @@ static void get_sectorsize(struct scsi_cd *cd)
 			cd->capacity = max_t(long, cd->capacity, last_written);
 
 		sector_size = get_unaligned_be32(&buffer[4]);
-		switch (sector_size) {
-			/*
-			 * HP 4020i CD-Recorder reports 2340 byte sectors
-			 * Philips CD-Writers report 2352 byte sectors
-			 *
-			 * Use 2k sectors for them..
-			 */
-		case 0:
-		case 2340:
-		case 2352:
+
+		/*
+		 * HP 4020i CD-Recorder reports 2340 byte sectors
+		 * Philips CD-Writers report 2352 byte sectors
+		 *
+		 * Use 2k sectors for them..
+		 */
+
+		if (!sector_size || sector_size == 2340 || sector_size == 2352)
 			sector_size = 2048;
-			/* fall through */
-		case 2048:
-			cd->capacity *= 4;
-			/* fall through */
-		case 512:
-			break;
-		default:
+
+		cd->capacity *= (sector_size >> SECTOR_SHIFT);
+
+		if (!blk_is_valid_logical_block_size(sector_size)) {
 			sr_printk(KERN_INFO, cd,
 				  "unsupported sector size %d.", sector_size);
 			cd->capacity = 0;
 		}
 
 		cd->device->sector_size = sector_size;
-
 		/*
 		 * Add this so that we have the ability to correctly gauge
 		 * what the device is capable of.
-- 
2.26.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ