* [PATCH] usb: host: xhci: fix coverity checker CONSTANT_EXPRESSION_RESULT warning
@ 2023-07-05 10:57 Li Jun
2023-07-05 16:28 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Li Jun @ 2023-07-05 10:57 UTC (permalink / raw)
To: mathias.nyman, gregkh; +Cc: linux-usb, aisheng.dong
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.
Signed-off-by: Li Jun <jun.li@nxp.com>
---
drivers/usb/host/xhci-ring.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
index 646ff125def5..847a1eadd17a 100644
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -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);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: host: xhci: fix coverity checker CONSTANT_EXPRESSION_RESULT warning
2023-07-05 10:57 [PATCH] usb: host: xhci: fix coverity checker CONSTANT_EXPRESSION_RESULT warning Li Jun
@ 2023-07-05 16:28 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2023-07-05 16:28 UTC (permalink / raw)
To: Li Jun; +Cc: mathias.nyman, linux-usb, aisheng.dong
On Wed, Jul 05, 2023 at 06:57:43PM +0800, Li Jun wrote:
> 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?
> So convert the dma address to be u64 when extract its upper 32 bits.
>
> Signed-off-by: Li Jun <jun.li@nxp.com>
What commit id does this fix?
> ---
> drivers/usb/host/xhci-ring.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c
> index 646ff125def5..847a1eadd17a 100644
> --- a/drivers/usb/host/xhci-ring.c
> +++ b/drivers/usb/host/xhci-ring.c
> @@ -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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-05 16:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-05 10:57 [PATCH] usb: host: xhci: fix coverity checker CONSTANT_EXPRESSION_RESULT warning Li Jun
2023-07-05 16:28 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).