]> git.baikalelectronics.ru Git - kernel.git/commitdiff
scsi: PC partition tables are little endian
authorChristoph Hellwig <hch@lst.de>
Wed, 1 Oct 2014 18:31:01 +0000 (20:31 +0200)
committerChristoph Hellwig <hch@lst.de>
Wed, 12 Nov 2014 10:15:54 +0000 (11:15 +0100)
As sparse correctly pointed out, scsi_partsize should use get_unaligned_le32
to read PC partition tables from disk, as they are little endian.

The result of this bug is that we returned incorrect geometries on big
endian systems when using the scsicam variant.  Which probably doesn't
matter as only old x86 systems every cared about the geometry.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
drivers/scsi/scsicam.c

index 92d24d6dcb395399da066c6604e830b0c775a482..910f4a7a39248a56ea7a123030551c90410fa30d 100644 (file)
@@ -163,8 +163,8 @@ int scsi_partsize(unsigned char *buf, unsigned long capacity,
                    end_head * end_sector + end_sector;
 
                /* This is the actual _sector_ number at the end */
-               logical_end = get_unaligned(&largest->start_sect)
-                   + get_unaligned(&largest->nr_sects);
+               logical_end = get_unaligned_le32(&largest->start_sect)
+                   + get_unaligned_le32(&largest->nr_sects);
 
                /* This is for >1023 cylinders */
                ext_cyl = (logical_end - (end_head * end_sector + end_sector))