Skip to contentSkip to conversation

scsi: isci: fix memcmp casting

PATCH New Ivan Bornyakov 1 participant 1 message May 24, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: isci: fix memcmp casting

memcmp() returns int, but variable of type u8 is used to store it. When casting int to u8, one can lose significant bits and get 0 from non-0 value returned by the memcmp().

---
 drivers/scsi/isci/host.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/isci/host.c +2 -2
index 1ee3868ade07..dd5f41e86639 100644
@@ -1786,7 +1786,7 @@ static void power_control_timeout(struct timer_list *t)
 				 * them out of await_sas_power state.
 				 */
 				if (requester != NULL && requester != iphy) {
-					u8 other = memcmp(requester->frame_rcvd.iaf.sas_addr,
+					int other = memcmp(requester->frame_rcvd.iaf.sas_addr,
 							  iphy->frame_rcvd.iaf.sas_addr,
 							  sizeof(requester->frame_rcvd.iaf.sas_addr));
 
@@ -1840,7 +1840,7 @@ void sci_controller_power_control_queue_insert(struct isci_host *ihost,
 		struct isci_phy *current_phy;
 
 		for (i = 0; i < SCI_MAX_PHYS; i++) {
-			u8 other;
+			int other;
 			current_phy = &ihost->phys[i];
 
 			other = memcmp(current_phy->frame_rcvd.iaf.sas_addr,
Signature · 1 line
2.16.1