cf7bf2
diff -ruN hdparm-9.54/hdparm.c hdparm-9.54/hdparm.c
cf7bf2
--- hdparm-9.54/hdparm.c	2021-04-26 15:05:54.000000000 +0100
cf7bf2
+++ hdparm-9.54/hdparm.c	2021-05-10 15:58:14.000000000 +0100
cf7bf2
@@ -1352,8 +1352,8 @@
cf7bf2
 			if (verbose)
cf7bf2
 				printf("GET_NATIVE_MAX_ADDRESS_EXT response: hob={%02x %02x %02x} lob={%02x %02x %02x}\n",
cf7bf2
 					   r.hob.lbah, r.hob.lbam, r.hob.lbal, r.lob.lbah, r.lob.lbam, r.lob.lbal);
cf7bf2
-			max = (((__u64)((r.hob.lbah << 16) | (r.hob.lbam << 8) | r.hob.lbal) << 24)
cf7bf2
-				   | ((r.lob.lbah << 16) | (r.lob.lbam << 8) | r.lob.lbal)) + 1;
cf7bf2
+			max = (((__u64)((r.hob.lbah << 16) | ((__u64)(r.hob.lbam << 8) | r.hob.lbal)) << 24)
cf7bf2
+				   | (__u64)((r.lob.lbah << 16) | (r.lob.lbam << 8) | r.lob.lbal)) + 1;
cf7bf2
 		}
cf7bf2
 	} else { // ACS2 or below, or optional AMAX not present
cf7bf2
 		if (SUPPORTS_48BIT_ADDR(id)) {
cf7bf2
@@ -1371,7 +1371,7 @@
cf7bf2
 					printf("READ_NATIVE_MAX_ADDRESS_EXT response: hob={%02x %02x %02x} lob={%02x %02x %02x}\n",
cf7bf2
 						r.hob.lbah, r.hob.lbam, r.hob.lbal, r.lob.lbah, r.lob.lbam, r.lob.lbal);
cf7bf2
 				max = (((__u64)((r.hob.lbah << 16) | (r.hob.lbam << 8) | r.hob.lbal) << 24)
cf7bf2
-				     	| ((r.lob.lbah << 16) | (r.lob.lbam << 8) | r.lob.lbal)) + 1;
cf7bf2
+				     	| ((__u64)(r.lob.lbah << 16) | (r.lob.lbam << 8) | r.lob.lbal)) + 1;
cf7bf2
 			}
cf7bf2
 		} else {
cf7bf2
 			/* DEVICE (3:0) / LBA (27:24) "remap" does NOT apply in ATA Status Return */
cf7bf2
@@ -1556,7 +1556,7 @@
cf7bf2
 	for (i = 0; i < nranges; ++i) {
cf7bf2
 		nsectors += sr->nsectors;
cf7bf2
 		range = sr->nsectors;
cf7bf2
-		range = (range << 48) | sr->lba;
cf7bf2
+		range = (__u64)(range << 48) | sr->lba;
cf7bf2
 		data[i] = __cpu_to_le64(range);
cf7bf2
 		++sr;
cf7bf2
 	}
cf7bf2
@@ -1742,7 +1742,7 @@
cf7bf2
 			err = errno;
cf7bf2
 			fprintf(stderr, "stdin: error at lba:count pair #%d: %s\n", (total_ranges + 1), strerror(err));
cf7bf2
 		} else {
cf7bf2
-			range = (nsect << 48) | lba;
cf7bf2
+			range = (__u64)(nsect << 48) | lba;
cf7bf2
 			nsectors += nsect;
cf7bf2
 			data[nranges++] = __cpu_to_le64(range);
cf7bf2
 			if (nranges == max_ranges) {
cf7bf2
@@ -2807,7 +2807,7 @@
cf7bf2
 					__u16 *dco = get_dco_identify_data(fd, 1);
cf7bf2
 					if (dco) {
cf7bf2
 						__u64 dco_max = dco[5];
cf7bf2
-						dco_max = ((((__u64)dco[5]) << 32) | (dco[4] << 16) | dco[3]) + 1;
cf7bf2
+						dco_max = ((((__u64)dco[5]) << 32) | ((__u64)dco[4] << 16) | (__u64)dco[3]) + 1;
cf7bf2
 						printf("(%llu?)", dco_max);
cf7bf2
 					}
cf7bf2
 					printf(", HPA setting seems invalid");
cf7bf2
diff -ruN hdparm-9.61/identify.c hdparm-9.62/identify.c
cf7bf2
--- hdparm-9.43/identify.c	2021-04-26 14:47:24.000000000 +0100
cf7bf2
+++ hdparm-9.43/identify.c	2021-05-10 15:51:23.000000000 +0100
cf7bf2
@@ -1531,7 +1531,7 @@
cf7bf2
 	else if (dco[2] & (1<<0)) printf(" udma0");
cf7bf2
 	putchar('\n');
cf7bf2
cf7bf2
-	lba = ((((__u64)dco[5]) << 32) | (dco[4] << 16) | dco[3]) + 1;
cf7bf2
+	lba = ((((__u64)dco[5]) << 32) | ((__u64)dco[4] << 16) | (__u64)dco[3]) + 1;
cf7bf2
 	printf("\tReal max sectors: %llu\n", lba);
cf7bf2
cf7bf2
 	printf("\tATA command/feature sets:");