Re: [PATCH] libata-core Use more robust parsing for multi_count

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Mark Lord wrote:
Alan Cox wrote:
+            switch (dev->id[59] & 0xff) {

Umm surely...

    if (n & (n - 1))
..

????
..

Ah.. backwards.  Thanks, Alan!  Revised patch follows:

-----

Make libata a little more robust in parsing the multi_count
field from a drive's identify data.  This prevents libata from
attempting to use dubious multi_count values ad infinitum.

Signed-off-by: Mark Lord <mlord@xxxxxxxxx>
--- upstream/drivers/ata/libata-core.c	2009-03-18 10:21:07.000000000 -0400
+++ new/drivers/ata/libata-core.c	2009-03-18 10:22:05.000000000 -0400
@@ -2426,9 +2426,12 @@

		dev->n_sectors = ata_id_n_sectors(id);

-		if (dev->id[59] & 0x100)
-			dev->multi_count = dev->id[59] & 0xff;
-
+		dev->multi_count = 0;
+		if (dev->id[59] & 0x100) {
+			int mc = dev->id[59] & 0xff;
+			if ((mc & (mc - 1)) == 0) /* even power of two? */
+				dev->multi_count = mc;
+		}
		if (ata_id_has_lba(id)) {
			const char *lba_desc;
			char ncq_desc[20];
--
To unsubscribe from this list: send the line "unsubscribe linux-ide" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystems]     [Linux SCSI]     [Linux RAID]     [Git]     [Kernel Newbies]     [Linux Newbie]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Samba]     [Device Mapper]

  Powered by Linux