Skip to content

Fix dfu infinite loop - #359

Open
adanila-cti wants to merge 1 commit into
realsenseai:devfrom
adanila-cti:dev
Open

Fix dfu infinite loop#359
adanila-cti wants to merge 1 commit into
realsenseai:devfrom
adanila-cti:dev

Conversation

@adanila-cti

Copy link
Copy Markdown

Minor patch to fix traversing up to the parent i2c node in ds5_dfu_device_open() and ds5_dfu_device_release(). The loops were setting parent back to it's initial value, so the if the condition was true it could never become false.

@ymodlin

ymodlin commented Feb 17, 2026

Copy link
Copy Markdown
Collaborator

I thank you for the contribution. I need to test this change if it will pass our internal CI I will merge it

Comment thread kernel/realsense/d4xx.c
/* get i2c controller and set dfu bus clock rate */
while (parent && i2c_parent_is_i2c_adapter(parent))
parent = i2c_parent_is_i2c_adapter(state->client->adapter);
parent = i2c_parent_is_i2c_adapter(parent);

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.

@copilot explain this change

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sorry if my explanation wasn't clear enough. I encountered this while using a device tree with nested i2c nodes. The bug is that parent is being set to the same value (the initial value) every iteration which, by the fact of reaching that line, is not able to falsify the while condition. state->client->adapter is not updated anywhere.

The solution I found is to instead call i2c_parent_is_i2c_adapter() on parent to traverse up the tree to the root i2c adapter. There is similar logic in the kernel's own i2c-mux.c: https://github.com/torvalds/linux/blob/master/drivers/i2c/i2c-mux.c#L220

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.

Confirmed — parent was re-derived from state->client->adapter every iteration, so the walk never advanced and spun forever behind an I2C mux. Passing parent matches i2c-mux.c. No bug found in the change.

It will need a rebase onto dev; the surrounding DFU code has moved since February.

Auto-generated by the rs-agentic bot.

@ymodlin

ymodlin commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

[rs-agentic] automated review — external contribution, bugs only.

No bugs found. The fix is correct: the loop condition advanced parent from state->client->adapter every iteration, so it never walked up the adapter chain and spun forever whenever the client sat behind an I2C mux. Passing parent makes the walk terminate, and both call sites (ds5_dfu_device_open() / ds5_dfu_device_release()) are fixed consistently.

Note this PR has been open since February and the surrounding DFU code has moved since — it will likely need a rebase onto dev before it can merge.

Auto-generated by the rs-agentic bot.

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.

2 participants