Skip to contentSkip to conversation

usb: host: xhci: fix coverity checker CONSTANT_EXPRESSION_RESULT warning

PATCH In review Li Jun 2 participants 2 messages Jul 5, 2023

Subsystems (2)
lore
Share & tools
lore

Li Jun

author
#0 lore raw

PATCH 1/1 usb: host: xhci: fix coverity checker CONSTANT_EXPRESSION_RESULT warning

CID 28889612: Operands don't affect result (CONSTANT_EXPRESSION_RESULT) result_independent_of_operands: urb->transfer_dma >> 16 >> 16 is 0 regardless of the values of its operands. This occurs as an argument to a function call.

So convert the dma address to be u64 when extract its upper 32 bits.

---
 drivers/usb/host/xhci-ring.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/host/xhci-ring.c +4 -4
index 646ff125def5..847a1eadd17a 100644
@@ -747,7 +747,7 @@ static int xhci_move_dequeue_past_td(struct xhci_hcd *xhci,
 		trb_sct = SCT_FOR_TRB(SCT_PRI_TR);
 	ret = queue_command(xhci, cmd,
 		lower_32_bits(addr) | trb_sct | new_cycle,
-		upper_32_bits(addr),
+		upper_32_bits((u64) addr),
 		STREAM_ID_FOR_TRB(stream_id), SLOT_ID_FOR_TRB(slot_id) |
 		EP_ID_FOR_TRB(ep_index) | TRB_TYPE(TRB_SET_DEQ), false);
 	if (ret < 0) {
@@ -4347,7 +4347,7 @@ int xhci_queue_address_device(struct xhci_hcd *xhci, struct xhci_command *cmd,
 		dma_addr_t in_ctx_ptr, u32 slot_id, enum xhci_setup_dev setup)
 {
 	return queue_command(xhci, cmd, lower_32_bits(in_ctx_ptr),
-			upper_32_bits(in_ctx_ptr), 0,
+			upper_32_bits((u64) in_ctx_ptr), 0,
 			TRB_TYPE(TRB_ADDR_DEV) | SLOT_ID_FOR_TRB(slot_id)
 			| (setup == SETUP_CONTEXT_ONLY ? TRB_BSR : 0), false);
 }
@@ -4373,7 +4373,7 @@ int xhci_queue_configure_endpoint(struct xhci_hcd *xhci,
 		u32 slot_id, bool command_must_succeed)
 {
 	return queue_command(xhci, cmd, lower_32_bits(in_ctx_ptr),
-			upper_32_bits(in_ctx_ptr), 0,
+			upper_32_bits((u64) in_ctx_ptr), 0,
 			TRB_TYPE(TRB_CONFIG_EP) | SLOT_ID_FOR_TRB(slot_id),
 			command_must_succeed);
 }
@@ -4383,7 +4383,7 @@ int xhci_queue_evaluate_context(struct xhci_hcd *xhci, struct xhci_command *cmd,
 		dma_addr_t in_ctx_ptr, u32 slot_id, bool command_must_succeed)
 {
 	return queue_command(xhci, cmd, lower_32_bits(in_ctx_ptr),
-			upper_32_bits(in_ctx_ptr), 0,
+			upper_32_bits((u64) in_ctx_ptr), 0,
 			TRB_TYPE(TRB_EVAL_CONTEXT) | SLOT_ID_FOR_TRB(slot_id),
 			command_must_succeed);
 }
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 4 lines · Li Jun

CID 28889612: Operands don't affect result (CONSTANT_EXPRESSION_RESULT) result_independent_of_operands: urb->transfer_dma >> 16 >> 16 is 0 regardless of the values of its operands. This occurs as an argument to a function call.

What does "CID BIGNUMBER" mean?

Quoted 3 lines

So convert the dma address to be u64 when extract its upper 32 bits.

What commit id does this fix?

Quoted 9 lines
---
 drivers/usb/host/xhci-ring.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/host/xhci-ring.c +0 -0
index 646ff125def5..847a1eadd17a 100644

drivers/usb/host/xhci-ring.c static int xhci_move_dequeue_past_td(struct xhci_hcd *xhci, · line 750

Quoted 5 lines
drivers/usb/host/xhci-ring.c +1 -1
@@ -747,7 +747,7 @@ static int xhci_move_dequeue_past_td(struct xhci_hcd *xhci,
 		trb_sct = SCT_FOR_TRB(SCT_PRI_TR);
 	ret = queue_command(xhci, cmd,
 		lower_32_bits(addr) | trb_sct | new_cycle,
-		upper_32_bits(addr),
+		upper_32_bits((u64) addr),

Is this really actually changing anything?

thanks,

greg k-h