Skip to content

Conversation

@aljazdu
Copy link

@aljazdu aljazdu commented Jan 23, 2026

Purpose

Added minor fixes to solve issues detected by ASAN/UBSAN.

Specification

This solves 2 issues, firstly: result of byte shift cannot be represented with type int and also a memory leak originating from missing unreferencing of a libusb device.

Dependencies & Potential Impact

None / not applicable

Deployment Plan

None / not applicable

Testing & Validation

This was tested with the sanitizers, and later using the HIL tests.

@aljazdu aljazdu requested a review from moratom January 23, 2026 12:31
@aljazdu aljazdu self-assigned this Jan 23, 2026
@moratom moratom requested review from asahtik and Copilot January 27, 2026 10:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses two issues detected by ASAN/UBSAN sanitizers: a potential integer overflow in a bit shift operation and a memory leak from an unreferenced libusb device.

Changes:

  • Fixed integer overflow by casting linkid to uint32_t before bit shifting in the COMBINE_IDS macro
  • Added libusb_unref_device() call to prevent memory leak after opening USB device

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
include/XLink/XLinkPrivateFields.h Cast linkid to uint32_t in COMBINE_IDS macro to prevent byte shift overflow
src/pc/protocols/usb_host.cpp Added libusb_unref_device call to properly release device reference after opening

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@asahtik asahtik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have one nitpick, otherwise LGTM

Co-authored-by: asahtik <38485424+asahtik@users.noreply.github.com>
@aljazdu aljazdu merged commit 38d0f08 into v3_develop Jan 28, 2026
28 checks passed
@aljazdu aljazdu deleted the fix/asan_ubsan_sanitizing branch January 28, 2026 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants