Skip to content

D401 gmsl fixes - #14582

Merged
Nir-Az merged 7 commits into
realsenseai:developmentfrom
remibettan:d401_gmsl_fixes
Jan 11, 2026
Merged

Nir-Az merged 7 commits into
realsenseai:developmentfrom
remibettan:d401_gmsl_fixes

Conversation

@remibettan

Copy link
Copy Markdown
Contributor

Tracked by: RSDSO-20657

@remibettan
remibettan requested a review from Nir-Az January 11, 2026 09:57
};

class rs401_gmsl_device : //public d400_color,
class rs401_gmsl_device : public d400_color,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Class now inherits d400_color; ensure _color_stream is initialized before use or guard its dereference.

Details

✨ AI Reasoning
​The class now publicly inherits and initializes the color subsystem but the device may not actually create or register the color stream in all codepaths. Later the code dereferences _color_stream (calling _color_stream.get()) when building matcher streams. If _color_stream is null (color not initialized for this SKU), dereferencing will cause a segmentation fault. This risk was introduced by enabling d400_color inheritance/initialization and then adding _color_stream to the matcher list without null checks.

🔧 How do I fix it?
Add null checks before dereferencing pointers, validate array bounds before access, avoid using pointers after free/delete, don't write to string literals, and prefer smart pointers in modern C++.

Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

std::shared_ptr<matcher> rs401_gmsl_device::create_matcher(const frame_holder& frame) const
{
std::vector<stream_interface*> streams = { _depth_stream.get() , _left_ir_stream.get() , _right_ir_stream.get() };
std::vector<stream_interface*> streams = { _depth_stream.get() , _left_ir_stream.get() , _right_ir_stream.get(), _color_stream.get() };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added _color_stream.get() to matcher streams without null-check; guard against null _color_stream before dereferencing.

Details

✨ AI Reasoning
​The create_matcher implementation was changed to include _color_stream.get() in the streams vector. This dereferences the shared pointer without checking whether the color stream was created/registered. If _color_stream is empty (nullptr), calling get() yields nullptr and passing that into matcher_factory can cause segmentation faults later when accessed. This is a direct regression compared to prior code that did not include the color stream here.

🔧 How do I fix it?
Add null checks before dereferencing pointers, validate array bounds before access, avoid using pointers after free/delete, don't write to string literals, and prefer smart pointers in modern C++.

Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ignored

@Nir-Az
Nir-Az requested a review from Copilot January 11, 2026 10:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 implements fixes for D401 GMSL device support, addressing platform detection, color sensor initialization, and video node enumeration.

Changes:

  • Enhanced platform detection to properly identify Jetson platforms in multi-pin UVC devices
  • Enabled color sensor support for RS401 GMSL devices by uncommenting inheritance and initialization code
  • Fixed device enumeration script to correctly parse device IDs and match video nodes

Reviewed changes

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

Show a summary per file
File Description
src/platform/uvc-device.h Implements proper Jetson platform detection by iterating through device elements
src/linux/backend-v4l2.cpp Adds blank line for code formatting
src/ds/d400/d400-factory.cpp Enables color sensor inheritance and stream matching for RS401 GMSL
src/ds/d400/d400-color.cpp Adds RS401_GMSL_PID exception to MIPI device color endpoint logic
scripts/rs-enum.sh Fixes device ID parsing and video node matching patterns

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

Comment thread src/platform/uvc-device.h Outdated
Comment on lines +387 to +391
for( auto & elem : _dev )
{
return elem->is_platform_jetson();
}
return false;

Copilot AI Jan 11, 2026

Copy link

Choose a reason for hiding this comment

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

The loop returns on the first iteration regardless of the result, making it functionally equivalent to checking only the first device. If all devices should be Jetson for this to return true, use a proper all-of check. If any device being Jetson is sufficient, the current logic works but the loop is misleading.

Suggested change
for( auto & elem : _dev )
{
return elem->is_platform_jetson();
}
return false;
if( _dev.empty() )
return false;
for( auto & elem : _dev )
{
if( ! elem->is_platform_jetson() )
return false;
}
return true;

Copilot uses AI. Check for mistakes.
Comment thread src/ds/d400/d400-color.cpp Resolved
Comment thread src/ds/d400/d400-color.cpp Outdated
@@ -65,7 +65,7 @@ namespace librealsense
// except for D405, in which the color is part of the depth unit

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

And D401 GMSL

Comment thread src/linux/backend-v4l2.cpp Outdated
mi = 3; // metadata node indicator
else if (ind == 6)
mi = 4; // IMU node indicator

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you revert the changes here?

Comment thread scripts/rs-enum.sh

# get cameras physical location
dfuid=($(ls -1 /sys/class/d4xx-class/ | awk -F'-' '{print $3"-"$4}'))
dfuid=($(ls -1 /sys/class/d4xx-class/ | awk -F'-' '{print $4}'))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Lets investigate why it did not work as discussed

Comment thread src/platform/uvc-device.h Outdated
{
for( auto & elem : _dev )
{
return elem->is_platform_jetson();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's change to check if we have the first device and return the function call from it or false

@Nir-Az
Nir-Az merged commit 1ea814c into realsenseai:development Jan 11, 2026
26 of 27 checks passed
@remibettan
remibettan deleted the d401_gmsl_fixes branch July 8, 2026 12:04
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