New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DM: xHCI: Check trb pointer before use it #6173
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
The trb pointer may be NULL when get the address from user space, add the pointer check before use the trb. Tracked-On: #6172 Signed-off-by: Liu Long <long.liu@intel.com> Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2627,6 +2627,10 @@ pci_xhci_complete_commands(struct pci_xhci_vdev *xdev) | |
| trb = xdev->opregs.cr_p; | ||
| ccs = xdev->opregs.crcr & XHCI_CRCR_LO_RCS; | ||
| crcr = xdev->opregs.crcr & ~0xF; | ||
| if (!trb) { | ||
| UPRINTF(LDBG, "Get the invalid guest address!\r\n"); | ||
| goto out; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh. I haven't noticed this gudieline, it required to be followed for both hypervisor and device model? The goto is everywhere even in Linux kernel... And there have hundreds goto in acrn-dm, we need a cleanup if it is needed. |
||
| } | ||
|
|
||
| while (1) { | ||
| xdev->opregs.cr_p = trb; | ||
|
|
@@ -2759,6 +2763,7 @@ pci_xhci_complete_commands(struct pci_xhci_vdev *xdev) | |
| } | ||
| } | ||
|
|
||
| out: | ||
| xdev->opregs.crcr = crcr | (xdev->opregs.crcr & XHCI_CRCR_LO_CA) | ccs; | ||
| xdev->opregs.crcr &= ~XHCI_CRCR_LO_CRR; | ||
| return 0; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the DM code honor the LOGLEVEL setting for reporting messages? Also, this isn't a very descriptive message for an ACRN user to understand what happened and what they should do.